Author: tn
Date: Sun Nov 8 21:04:34 2015
New Revision: 1713293
URL: http://svn.apache.org/viewvc?rev=1713293&view=rev
Log:
Backport COLLECTIONS-261 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=1713293&r1=1713292&r2=1713293&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 21:04:34 2015
@@ -42,6 +42,10 @@
<action issue="COLLECTIONS-266" dev="bayard" type="fix" due-to="Joerg
Schaible">
"MultiKey" will now be correctly serialized/de-serialized.
</action>
+ <action issue="COLLECTIONS-261" dev="bayard" type="fix" due-to="ori">
+ "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-249" dev="bayard" type="fix" due-to="Joe Kelly">
"SetUniqueList.addAll(int, Collection)" now correctly add the collection
at the
provided index.
@@ -85,10 +89,6 @@
<action issue="COLLECTIONS-304" dev="bayard" type="fix" due-to="RafaÅ
Figas,Bjorn Townsend">
"SetUniqueList#set(int, Object)" will now correctly enforce the
uniqueness constraint.
</action>
- <action issue="COLLECTIONS-261" dev="bayard" type="fix" due-to="ori">
- "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>
-->
</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=1713293&r1=1713292&r2=1713293&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 21:04:34 2015
@@ -416,7 +416,7 @@ public class Flat3Map implements Iterabl
return old;
}
if (key2 == null) {
- Object old = value3;
+ Object old = value2;
hash2 = hash3;
key2 = key3;
value2 = value3;
@@ -427,7 +427,7 @@ public class Flat3Map implements Iterabl
return old;
}
if (key1 == null) {
- Object old = value3;
+ Object old = value1;
hash1 = hash3;
key1 = key3;
value1 = value3;
@@ -448,7 +448,7 @@ public class Flat3Map implements Iterabl
return old;
}
if (key1 == null) {
- Object old = value2;
+ Object old = value1;
hash1 = hash2;
key1 = key2;
value1 = value2;
@@ -483,7 +483,7 @@ public class Flat3Map implements Iterabl
return old;
}
if (hash2 == hashCode && key.equals(key2)) {
- Object old = value3;
+ Object old = value2;
hash2 = hash3;
key2 = key3;
value2 = value3;
@@ -494,7 +494,7 @@ public class Flat3Map implements Iterabl
return old;
}
if (hash1 == hashCode && key.equals(key1)) {
- Object old = value3;
+ Object old = value1;
hash1 = hash3;
key1 = key3;
value1 = value3;
@@ -515,7 +515,7 @@ public class Flat3Map implements Iterabl
return old;
}
if (hash1 == hashCode && key.equals(key1)) {
- Object old = value2;
+ Object old = value1;
hash1 = hash2;
key1 = key2;
value1 = value2;
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=1713293&r1=1713292&r2=1713293&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 21:04:34 2015
@@ -205,6 +205,21 @@ public class TestFlat3Map extends Abstra
assertSame(TWO, cloned.get(TWENTY));
}
+ public void testCollections261() {
+ final Flat3Map m = new Flat3Map();
+ m.put( Integer.valueOf(1), Integer.valueOf(1) );
+ m.put( Integer.valueOf(0), Integer.valueOf(0) );
+ assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) );
+ assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) );
+
+ m.put( Integer.valueOf(2), Integer.valueOf(2) );
+ m.put( Integer.valueOf(1), Integer.valueOf(1) );
+ m.put( Integer.valueOf(0), Integer.valueOf(0) );
+ assertEquals( Integer.valueOf(2), m.remove( Integer.valueOf(2) ) );
+ assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) );
+ assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) );
+ }
+
public void testSerialisation0() throws Exception {
Flat3Map map = new Flat3Map();
ByteArrayOutputStream bout = new ByteArrayOutputStream();