Backport COLLECTIONS-261 to 3.2.2

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_X@1713293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2015-11-08 21:04:34 +00:00
parent 46e5a83207
commit 6a7d35dea2
3 changed files with 25 additions and 10 deletions

View File

@ -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>

View File

@ -416,7 +416,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable {
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 IterableMap, Serializable, Cloneable {
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 IterableMap, Serializable, Cloneable {
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 IterableMap, Serializable, Cloneable {
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 IterableMap, Serializable, Cloneable {
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 IterableMap, Serializable, Cloneable {
return old;
}
if (hash1 == hashCode && key.equals(key1)) {
Object old = value2;
Object old = value1;
hash1 = hash2;
key1 = key2;
value1 = value2;

View File

@ -205,6 +205,21 @@ public class TestFlat3Map extends AbstractTestIterableMap {
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();