ARTEMIS-1664 fix npe bug while getting element in the process of rehash
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/6509c078 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/6509c078 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/6509c078 Branch: refs/heads/master Commit: 6509c078fb4e4a60b40a4a44528453541caabb4b Parents: 3ff0dc2 Author: yang wei <[email protected]> Authored: Mon Feb 5 18:12:18 2018 +0800 Committer: Clebert Suconic <[email protected]> Committed: Thu Feb 22 20:47:42 2018 -0500 ---------------------------------------------------------------------- .../artemis/utils/collections/ConcurrentLongHashMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6509c078/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java ---------------------------------------------------------------------- diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java index 8af0660..34a0e60 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashMap.java @@ -199,7 +199,7 @@ public class ConcurrentLongHashMap<V> { private long[] keys; private V[] values; - private int capacity; + private volatile int capacity; private volatile int size; private int usedBuckets; private int resizeThreshold; @@ -457,10 +457,10 @@ public class ConcurrentLongHashMap<V> { } } - capacity = newCapacity; keys = newKeys; values = newValues; usedBuckets = size; + capacity = newCapacity; resizeThreshold = (int) (capacity * MapFillFactor); }
