You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/11/09 21:53:04 UTC
svn commit: r1713536 - in
/commons/proper/collections/branches/COLLECTIONS_3_2_X/src:
changes/changes.xml java/org/apache/commons/collections/list/TreeList.java
test/org/apache/commons/collections/list/TestTreeList.java
Author: tn
Date: Mon Nov 9 20:53:04 2015
New Revision: 1713536
URL: http://svn.apache.org/viewvc?rev=1713536&view=rev
Log:
Backport COLLECTIONS-447 to 3.2.2.
Modified:
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/list/TreeList.java
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/list/TestTreeList.java
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml?rev=1713536&r1=1713535&r2=1713536&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml Mon Nov 9 20:53:04 2015
@@ -22,7 +22,6 @@
<body>
<release version="3.2.2" date="20XX-XX-XX" description="This is a bugfix release.">
-
<action issue="COLLECTIONS-580" dev="tn" type="update">
De-serialization of "InvokerTransformer" is disabled by default as this
can be exploited for remote code execution attacks. To re-enable the
@@ -35,6 +34,10 @@
permission to read system properties, the "File#separator" field will
be used instead.
</action>
+ <action issue="COLLECTIONS-447" dev="tn" type="fix" due-to="Jeffrey Barnes">
+ Tree traversal with a TreeListIterator will not be affected anymore by
+ the removal of an element directly after a call to previous().
+ </action>
<action issue="COLLECTIONS-444" dev="tn" type="fix" due-to="Thomas Vahrst, John Vasileff">
SetUniqueList.set(int, Object) now works correctly if the object to be inserted
is already placed at the given position.
@@ -81,14 +84,6 @@
Calling "setValue(Object)" on any Entry returned by a "Flat3Map" will now
correctly set the value for the current entry.
</action>
-
- <!-- Bugfixes planned to backport from 4.0
-
- <action issue="COLLECTIONS-447" dev="tn" type="fix" due-to="Jeffrey Barnes">
- Tree traversal with a TreeListIterator will not be affected anymore by
- the removal of an element directly after a call to previous().
- </action>
- -->
</release>
</body>
</document>
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/list/TreeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/list/TreeList.java?rev=1713536&r1=1713535&r2=1713536&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/list/TreeList.java (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/list/TreeList.java Mon Nov 9 20:53:04 2015
@@ -881,15 +881,14 @@ public class TreeList extends AbstractLi
if (currentIndex == -1) {
throw new IllegalStateException();
}
- if (nextIndex == currentIndex) {
- // remove() following previous()
- next = next.next();
- parent.remove(currentIndex);
- } else {
+ parent.remove(currentIndex);
+ if (nextIndex != currentIndex) {
// remove() following next()
- parent.remove(currentIndex);
nextIndex--;
}
+ // the AVL node referenced by next may have become stale after a remove
+ // reset it now: will be retrieved by next call to next()/previous() via nextIndex
+ next = null;
current = null;
currentIndex = -1;
expectedModCount++;
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/list/TestTreeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/list/TestTreeList.java?rev=1713536&r1=1713535&r2=1713536&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/list/TestTreeList.java (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/list/TestTreeList.java Mon Nov 9 20:53:04 2015
@@ -242,4 +242,19 @@ public class TestTreeList extends Abstra
assertEquals(false, li.hasNext());
}
+ public void testBugCollections447() {
+ final List treeList = new TreeList();
+ treeList.add("A");
+ treeList.add("B");
+ treeList.add("C");
+ treeList.add("D");
+ final ListIterator li = treeList.listIterator();
+ assertEquals("A", li.next());
+ assertEquals("B", li.next());
+ assertEquals("B", li.previous());
+ li.remove(); // Deletes "B"
+ // previous() after remove() should move to
+ // the element before the one just removed
+ assertEquals("A", li.previous());
+ }
}