Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Developing Analytics Applications
SlotIterator.remove does not comply with java.util.Iterator.remove
Migrateduser
<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
There are no comments yet