Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
SlotIterator.remove does not comply with java.util.Iterator.remove
Barney
<p>Pretty straightforward... when removing items using a SlotIterator it does not comply with the java.util.Iterator requirements.<br><br>
This code fails to remove the first element from the collection:</p>
<pre class="_prettyXprint">
Iterator iter = design.getDataSources().iterator();
while (iter.hasNext()) {
Object dataSource = iter.next();
// do something with dataSource...
iter.remove();
}</pre>
<p>As a work around, I have to do two passes:</p>
<pre class="_prettyXprint">
Iterator iter1 = design.getDataSources().iterator();
while (iter1.hasNext()) {
Object dataSource = iter1.next();
// do something with dataSource...
}
Iterator iter2 = design.getDataSources().iterator();
while (iter2.hasNext()) {
iter2.remove();
}</pre>
<p>Although the second pass does actually work, it should throw an IllegalStateException, as per the java.util.Iterator#remove Java docs:</p>
<p> </p>
<blockquote class="ipsBlockquote">Throws: IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.
<p> </p>
</blockquote>
<p>
Looks like a fairly simple problem in the SlotIterator class. Still seems to be present in 4.4.2. I would raise it as a bug, but not sure where to do that.</p>
Find more posts tagged with
Comments
mwilliams
You can file bugs at eclipse.org/birt. You'll find a link to the bugzilla in the community section.
Barney
<p>Ok thanks - wil do that - wasn't sure if it was still current with all the stuff that has moved over to the Actuate site.</p>