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/08 21:21:27 UTC
svn commit: r1713290 - in
/commons/proper/collections/branches/COLLECTIONS_3_2_X/src:
changes/changes.xml java/org/apache/commons/collections/map/Flat3Map.java
test/org/apache/commons/collections/map/TestFlat3Map.java
Author: tn
Date: Sun Nov 8 20:21:27 2015
New Revision: 1713290
URL: http://svn.apache.org/viewvc?rev=1713290&view=rev
Log:
Backport COLLECTIONS-217 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/map/Flat3Map.java
commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/map/TestFlat3Map.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=1713290&r1=1713289&r2=1713290&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 Sun Nov 8 20:21:27 2015
@@ -53,6 +53,10 @@
<action issue="COLLECTIONS-219" dev="scolebourne" type="fix" due-to="Tom Leccese">
"CollectionUtils#removeAll" wrongly called "ListUtils#retainAll".
</action>
+ <action issue="COLLECTIONS-217" dev="scolebourne" type="fix" due-to="Matt Bishop">
+ 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
@@ -85,10 +89,6 @@
"Flat3Map#remove(Object)" will now return the correct value mapped to the removed key
if the size of the map is less or equal 3.
</action>
- <action issue="COLLECTIONS-217" dev="scolebourne" type="fix" due-to="Matt Bishop">
- Calling "setValue(Object)" on any Entry returned by a "Flat3Map" will now
- correctly set the value for the current entry.
- </action>
-->
</release>
</body>
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/map/Flat3Map.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/map/Flat3Map.java?rev=1713290&r1=1713289&r2=1713290&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/map/Flat3Map.java (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/map/Flat3Map.java Sun Nov 8 20:21:27 2015
@@ -804,10 +804,13 @@ public class Flat3Map implements Iterabl
switch (nextIndex) {
case 3:
parent.value3 = value;
+ break;
case 2:
parent.value2 = value;
+ break;
case 1:
parent.value1 = value;
+ break;
}
return old;
}
Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/map/TestFlat3Map.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/map/TestFlat3Map.java?rev=1713290&r1=1713289&r2=1713290&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/map/TestFlat3Map.java (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/map/TestFlat3Map.java Sun Nov 8 20:21:27 2015
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.Iterator;
import java.util.Map;
import junit.framework.Test;
@@ -40,8 +41,10 @@ public class TestFlat3Map extends Abstra
private static final Integer ONE = new Integer(1);
private static final Integer TWO = new Integer(2);
+ private static final Integer THREE = new Integer(3);
private static final String TEN = "10";
private static final String TWENTY = "20";
+ private static final String THIRTY = "30";
public TestFlat3Map(String testName) {
super(testName);
@@ -60,6 +63,64 @@ public class TestFlat3Map extends Abstra
}
//-----------------------------------------------------------------------
+ public void testEntryIteratorSetValue1() throws Exception {
+ final Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ final Iterator it = map.entrySet().iterator();
+ final Map.Entry entry = (Map.Entry) it.next();
+ entry.setValue("NewValue");
+ assertEquals(3, map.size());
+ assertEquals(true, map.containsKey(ONE));
+ assertEquals(true, map.containsKey(TWO));
+ assertEquals(true, map.containsKey(THREE));
+ assertEquals("NewValue", map.get(ONE));
+ assertEquals(TWENTY, map.get(TWO));
+ assertEquals(THIRTY, map.get(THREE));
+ }
+
+ public void testEntryIteratorSetValue2() throws Exception {
+ final Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ final Iterator it = map.entrySet().iterator();
+ it.next();
+ final Map.Entry entry = (Map.Entry) it.next();
+ entry.setValue("NewValue");
+ assertEquals(3, map.size());
+ assertEquals(true, map.containsKey(ONE));
+ assertEquals(true, map.containsKey(TWO));
+ assertEquals(true, map.containsKey(THREE));
+ assertEquals(TEN, map.get(ONE));
+ assertEquals("NewValue", map.get(TWO));
+ assertEquals(THIRTY, map.get(THREE));
+ }
+
+ public void testEntryIteratorSetValue3() throws Exception {
+ final Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ final Iterator it = map.entrySet().iterator();
+ it.next();
+ it.next();
+ final Map.Entry entry = (Map.Entry) it.next();
+ entry.setValue("NewValue");
+ assertEquals(3, map.size());
+ assertEquals(true, map.containsKey(ONE));
+ assertEquals(true, map.containsKey(TWO));
+ assertEquals(true, map.containsKey(THREE));
+ assertEquals(TEN, map.get(ONE));
+ assertEquals(TWENTY, map.get(TWO));
+ assertEquals("NewValue", map.get(THREE));
+ }
+
+ //-----------------------------------------------------------------------
public void testEquals1() {
Flat3Map map1 = new Flat3Map();
map1.put("a", "testA");