You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/07/11 17:55:42 UTC
[12/50] commons-collections git commit: Backport COLLECTIONS-217 to
3.2.2
Backport COLLECTIONS-217 to 3.2.2
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_X@1713290 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/46e5a832
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/46e5a832
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/46e5a832
Branch: refs/heads/COLLECTIONS_3_2_X
Commit: 46e5a83207196e5ef5f97fc123b8862190429931
Parents: c0da312
Author: Thomas Neidhart <tn...@apache.org>
Authored: Sun Nov 8 20:21:27 2015 +0000
Committer: Thomas Neidhart <tn...@apache.org>
Committed: Sun Nov 8 20:21:27 2015 +0000
----------------------------------------------------------------------
src/changes/changes.xml | 8 +--
.../commons/collections/map/Flat3Map.java | 3 +
.../commons/collections/map/TestFlat3Map.java | 61 ++++++++++++++++++++
3 files changed, 68 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/46e5a832/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 683723b..bccc7e1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -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>
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/46e5a832/src/java/org/apache/commons/collections/map/Flat3Map.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/map/Flat3Map.java b/src/java/org/apache/commons/collections/map/Flat3Map.java
index 518842b..19085f1 100644
--- a/src/java/org/apache/commons/collections/map/Flat3Map.java
+++ b/src/java/org/apache/commons/collections/map/Flat3Map.java
@@ -804,10 +804,13 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable {
switch (nextIndex) {
case 3:
parent.value3 = value;
+ break;
case 2:
parent.value2 = value;
+ break;
case 1:
parent.value1 = value;
+ break;
}
return old;
}
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/46e5a832/src/test/org/apache/commons/collections/map/TestFlat3Map.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/commons/collections/map/TestFlat3Map.java b/src/test/org/apache/commons/collections/map/TestFlat3Map.java
index 9359602..427b7ae 100644
--- a/src/test/org/apache/commons/collections/map/TestFlat3Map.java
+++ b/src/test/org/apache/commons/collections/map/TestFlat3Map.java
@@ -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 AbstractTestIterableMap {
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 AbstractTestIterableMap {
}
//-----------------------------------------------------------------------
+ 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");