You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2005/07/15 01:11:15 UTC
svn commit: r219131 - in /jakarta/commons/proper/collections/trunk:
RELEASE-NOTES.html project.xml
src/java/org/apache/commons/collections/bag/AbstractMapBag.java
src/test/org/apache/commons/collections/bag/AbstractTestBag.java
Author: scolebourne
Date: Thu Jul 14 16:11:12 2005
New Revision: 219131
URL: http://svn.apache.org/viewcvs?rev=219131&view=rev
Log:
AbstractMapBag.BagIterator.remove breaks class invariants when removing last entry
bug 35747, from Steve Clark
Modified:
jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html
jakarta/commons/proper/collections/trunk/project.xml
jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
Modified: jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html?rev=219131&r1=219130&r2=219131&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html (original)
+++ jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html Thu Jul 14 16:11:12 2005
@@ -83,6 +83,7 @@
<li>MultiHashMap.putAll(multimap) - Was adding the collection as a single item rather than individually [35631]</li>
<li>Flat3Map.equals() - Fix to make flat mode comparison actually work [34917]</li>
<li>TransformedMap.putAll - Now allows putAll of an empty map [34686]</li>
+<li>AbstractMapBag.BagIterator.remove - Removing the last entry used to break the class invariants [35747]</li>
<li>BoundedFifoBuffer/CircularFifoBuffer - Fix serialization to work in case where buffer serialized when full [31433]</li>
<li>BoundedFifoBuffer - Fix iterator remove bug causing ArrayIndexOutOfBounds error [33071]</li>
<li>IteratorChain.remove() - Fix to avoid IllegalStateException when one of the underlying iterators is a FilterIterator [34267]</li>
Modified: jakarta/commons/proper/collections/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/project.xml?rev=219131&r1=219130&r2=219131&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/project.xml (original)
+++ jakarta/commons/proper/collections/trunk/project.xml Thu Jul 14 16:11:12 2005
@@ -172,6 +172,9 @@
<name>Ram Chidambaram</name>
</contributor>
<contributor>
+ <name>Steve Clark</name>
+ </contributor>
+ <contributor>
<name>Eric Crampton</name>
</contributor>
<contributor>
Modified: jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java?rev=219131&r1=219130&r2=219131&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java (original)
+++ jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java Thu Jul 14 16:11:12 2005
@@ -43,6 +43,7 @@
* @author Michael A. Smith
* @author Stephen Colebourne
* @author Janek Bogucki
+ * @author Steve Clark
*/
public abstract class AbstractMapBag implements Bag {
@@ -221,12 +222,12 @@
throw new IllegalStateException();
}
MutableInteger mut = (MutableInteger) current.getValue();
- if (mut.value > 0) {
+ if (mut.value > 1) {
mut.value--;
- parent.size--;
} else {
entryIterator.remove();
}
+ parent.size--;
canRemove = false;
}
}
Modified: jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java?rev=219131&r1=219130&r2=219131&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java (original)
+++ jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/bag/AbstractTestBag.java Thu Jul 14 16:11:12 2005
@@ -319,6 +319,27 @@
assertEquals(1, bag.size());
}
+ public void testIteratorRemoveProtectsInvariants() {
+ Bag bag = makeBag();
+ bag.add("A");
+ bag.add("A");
+ assertEquals(2, bag.size());
+ Iterator it = bag.iterator();
+ assertEquals("A", it.next());
+ assertEquals(true, it.hasNext());
+ it.remove();
+ assertEquals(1, bag.size());
+ assertEquals(true, it.hasNext());
+ assertEquals("A", it.next());
+ assertEquals(false, it.hasNext());
+ it.remove();
+ assertEquals(0, bag.size());
+ assertEquals(false, it.hasNext());
+
+ Iterator it2 = bag.iterator();
+ assertEquals(false, it2.hasNext());
+ }
+
public void testToArray() {
Bag bag = makeBag();
bag.add("A");
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org