cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject [2/2] cxf git commit: [CXF-7339] Null key support in CacheMap
Date Wed, 26 Apr 2017 15:47:44 GMT
[CXF-7339] Null key support in CacheMap


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c74fd386
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c74fd386
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c74fd386

Branch: refs/heads/3.1.x-fixes
Commit: c74fd38620b905b096e02dd987e6a97bc5e0a616
Parents: a0aa234
Author: Alessio Soldano <asoldano@redhat.com>
Authored: Wed Apr 26 16:25:34 2017 +0200
Committer: Alessio Soldano <asoldano@redhat.com>
Committed: Wed Apr 26 17:46:41 2017 +0200

----------------------------------------------------------------------
 core/src/main/java/org/apache/cxf/common/util/CacheMap.java     | 2 +-
 core/src/test/java/org/apache/cxf/common/util/CacheMapTest.java | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c74fd386/core/src/main/java/org/apache/cxf/common/util/CacheMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/CacheMap.java b/core/src/main/java/org/apache/cxf/common/util/CacheMap.java
index 15b6963..1f4b820 100644
--- a/core/src/main/java/org/apache/cxf/common/util/CacheMap.java
+++ b/core/src/main/java/org/apache/cxf/common/util/CacheMap.java
@@ -123,7 +123,7 @@ public class CacheMap<K, V> implements Map<K, V> {
         Set<K> keys = new HashSet<>(extraKeyMap.keySet());
         V v2 = extraKeyMap.remove(key);
         for (K nk : keys) {
-            if (key.equals(nk)) {
+            if ((key != null && key.equals(nk)) || (key == null && nk ==
null)) {
                 V v3 = extraKeyMap.remove(nk);
                 if (v2 == null) {
                     v2 = v3;

http://git-wip-us.apache.org/repos/asf/cxf/blob/c74fd386/core/src/test/java/org/apache/cxf/common/util/CacheMapTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/common/util/CacheMapTest.java b/core/src/test/java/org/apache/cxf/common/util/CacheMapTest.java
index cdec8e4..62cc4c5 100644
--- a/core/src/test/java/org/apache/cxf/common/util/CacheMapTest.java
+++ b/core/src/test/java/org/apache/cxf/common/util/CacheMapTest.java
@@ -39,12 +39,15 @@ public class CacheMapTest {
         String putKey = "test";
         definitions.put(putKey, putValue);
         
+        Assert.assertNull(definitions.remove(null));
+
         String removeKey = new String("test");
         Object removeValue = definitions.remove(removeKey);
         
         Assert.assertEquals(putKey, removeKey);
         Assert.assertEquals(putValue, removeValue);
         Assert.assertTrue(definitions.isEmpty());
+        Assert.assertNull(definitions.remove(null));
     }
 
 }


Mime
View raw message