DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=35733>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=35733 Summary: Iterator.remove() in UnboundedFifoBuffer does not work Product: Commons Version: 3.1 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Collections AssignedTo: commons-dev@jakarta.apache.org ReportedBy: [EMAIL PROTECTED] The implementation of Iterator.remove() in the unbounded fifo buffer is buggy. It produces an ArrayIndexOutOfBoundExceptions when it needs to swap around the end of the array to its start. The code should be: public void remove() { if (lastReturnedIndex == -1) { throw new IllegalStateException(); } // First element can be removed quickly if (lastReturnedIndex == head) { UnboundedFifoBuffer.this.remove(); lastReturnedIndex = -1; return; } // Other elements require us to shift the subsequent elements /* * This loop is buggy in the original implementation! */ int i = lastReturnedIndex + 1; while (i != tail) { buffer[decrement(i)] = buffer[i]; i = increment(i); } lastReturnedIndex = -1; tail = decrement(tail); buffer[tail] = null; index = decrement(index); } while the original buggy loop is: // Other elements require us to shift the subsequent elements int i = lastReturnedIndex + 1; while (i != tail) { if (i >= buffer.length) { buffer[i - 1] = buffer[0]; i = 0; } else { buffer[i - 1] = buffer[i]; i++; } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]