This is an automated email from the ASF dual-hosted git repository. deki pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push: new 88c493b [CXF-7824] CacheMap may have spurious null keys 88c493b is described below commit 88c493bd64ceb68f24301b50c6e795f47526c566 Author: Dennis Kieselhorst <d...@apache.org> AuthorDate: Thu Aug 30 12:25:52 2018 +0200 [CXF-7824] CacheMap may have spurious null keys --- .../cxf/common/util/WeakIdentityHashMap.java | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java b/core/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java index 143440c..5f24946 100644 --- a/core/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java +++ b/core/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java @@ -73,19 +73,23 @@ public class WeakIdentityHashMap<K, V> implements Map<K, V> { Set<Map.Entry<K, V>> ret = new HashSet<Map.Entry<K, V>>(); for (Map.Entry<IdentityWeakReference, V> ref : backingStore.entrySet()) { final K key = ref.getKey().get(); - final V value = ref.getValue(); - Map.Entry<K, V> entry = new Map.Entry<K, V>() { - public K getKey() { - return key; - } - public V getValue() { - return value; - } - public V setValue(V value) { - throw new UnsupportedOperationException(); - } - }; - ret.add(entry); + if (key != null) { + final V value = ref.getValue(); + Map.Entry<K, V> entry = new Map.Entry<K, V>() { + public K getKey() { + return key; + } + + public V getValue() { + return value; + } + + public V setValue(V value) { + throw new UnsupportedOperationException(); + } + }; + ret.add(entry); + } } return Collections.unmodifiableSet(ret); } @@ -93,7 +97,10 @@ public class WeakIdentityHashMap<K, V> implements Map<K, V> { reap(); Set<K> ret = new HashSet<>(); for (IdentityWeakReference ref : backingStore.keySet()) { - ret.add(ref.get()); + K key = ref.get(); + if (key != null) { + ret.add(key); + } } return Collections.unmodifiableSet(ret); }