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 2014/05/06 23:38:06 UTC
svn commit: r1592893 - in /commons/proper/collections/trunk/src:
changes/changes.xml
main/java/org/apache/commons/collections4/map/MultiKeyMap.java
test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java
Author: tn
Date: Tue May 6 21:38:05 2014
New Revision: 1592893
URL: http://svn.apache.org/r1592893
Log:
[COLLECTIONS-521] Fix MultiKeyMap when using two key arguments and the second is null. Thanks to Maxime Nay.
Modified:
commons/proper/collections/trunk/src/changes/changes.xml
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java
Modified: commons/proper/collections/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/changes/changes.xml?rev=1592893&r1=1592892&r2=1592893&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/changes/changes.xml (original)
+++ commons/proper/collections/trunk/src/changes/changes.xml Tue May 6 21:38:05 2014
@@ -22,6 +22,10 @@
<body>
<release version="4.1" date="TBD" description="">
+ <action issue="COLLECTIONS-521" dev="tn" type="fix" due-to="Maxime Nay">
+ "MultiKeyMap" was throwing a "NullPointerException" for various operations
+ if two key arguments have been used and the second was "null".
+ </action>
<action issue="COLLECTIONS-522" dev="tn" type="fix" due-to="Erik">
Updated code example for "PredicatedList".
</action>
Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java?rev=1592893&r1=1592892&r2=1592893&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java (original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java Tue May 6 21:38:05 2014
@@ -249,7 +249,7 @@ public class MultiKeyMap<K, V> extends A
return
multi.size() == 2 &&
(key1 == multi.getKey(0) || key1 != null && key1.equals(multi.getKey(0))) &&
- (key2 == multi.getKey(1) || key1 != null && key2.equals(multi.getKey(1)));
+ (key2 == multi.getKey(1) || key2 != null && key2.equals(multi.getKey(1)));
}
//-----------------------------------------------------------------------
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java?rev=1592893&r1=1592892&r2=1592893&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java Tue May 6 21:38:05 2014
@@ -300,6 +300,22 @@ public class MultiKeyMapTest<K, V> exten
}
}
+ public void testMultiKeyPutWithNullKey() {
+ final MultiKeyMap<String, String> map = new MultiKeyMap<String, String>();
+ map.put("a", null, "value1");
+ map.put("b", null, "value2");
+ map.put("c", null, "value3");
+ map.put("a", "z", "value4");
+ map.put("a", null, "value5");
+ map.put(null, "a", "value6");
+ map.put(null, null, "value7");
+
+ assertEquals(6, map.size());
+ assertEquals("value5", map.get("a", null));
+ assertEquals("value4", map.get("a", "z"));
+ assertEquals("value6", map.get(null, "a"));
+ }
+
public void testMultiKeyRemove() {
final MultiKey<K>[] keys = getMultiKeyKeys();
final V[] values = getSampleValues();