ARTEMIS-1664 fix npe bug while getting element in the process of rehash

Apply same fix to ConcurrentLongHashSet

Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2c32dda3
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2c32dda3
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2c32dda3

Branch: refs/heads/master
Commit: 2c32dda39e4edab7d34e3fb0db8217944df33977
Parents: 6509c07
Author: Michael André Pearce <michael.andre.pea...@me.com>
Authored: Thu Feb 22 23:20:56 2018 +0000
Committer: Clebert Suconic <clebertsuco...@apache.org>
Committed: Thu Feb 22 20:47:42 2018 -0500

----------------------------------------------------------------------
 .../artemis/utils/collections/ConcurrentLongHashSet.java         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2c32dda3/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java
----------------------------------------------------------------------
diff --git 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java
 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java
index 17d94b7..8344c57 100644
--- 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java
+++ 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java
@@ -165,7 +165,7 @@ public class ConcurrentLongHashSet {
       // Keys and values are stored interleaved in the table array
       private long[] table;
 
-      private int capacity;
+      private volatile int capacity;
       private volatile int size;
       private int usedBuckets;
       private int resizeThreshold;
@@ -374,9 +374,9 @@ public class ConcurrentLongHashSet {
             }
          }
 
-         capacity = newCapacity;
          table = newTable;
          usedBuckets = size;
+         capacity = newCapacity;
          resizeThreshold = (int) (capacity * SetFillFactor);
       }
 

Reply via email to