You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by de...@apache.org on 2018/08/30 10:31:23 UTC
[cxf] branch 3.2.x-fixes updated: [CXF-7824] CacheMap may have
spurious null keys
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.2.x-fixes by this push:
new 6ac716d [CXF-7824] CacheMap may have spurious null keys
6ac716d is described below
commit 6ac716dab6f90c6e9e1a9f408a4b8c758df9465f
Author: Dennis Kieselhorst <de...@apache.org>
AuthorDate: Thu Aug 30 12:25:52 2018 +0200
[CXF-7824] CacheMap may have spurious null keys
(cherry picked from commit 88c493bd64ceb68f24301b50c6e795f47526c566)
---
.../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);
}