[ https://issues.apache.org/jira/browse/ARTEMIS-1664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16374008#comment-16374008 ]
ASF GitHub Bot commented on ARTEMIS-1664: ----------------------------------------- Github user wy96f commented on the issue: https://github.com/apache/activemq-artemis/pull/1851 Sorry for the late reply. Using lazySet to update capacity filed is a good point. As for the test, I modified test as follows: @Test public void concurrentInsertionsAndReads() throws Throwable { ExecutorService executor = Executors.newCachedThreadPool(); for (int x = 0; x < 1000; x++) { ConcurrentLongHashMap<String> map = new ConcurrentLongHashMap<>(1, 1); final int nThreads = 16; final int N = 100_000; String value = "v"; List<Future<?>> futures = new ArrayList<>(); for (int i = 0; i < nThreads; i++) { futures.add(executor.submit(() -> { Random random = new Random(); for (int j = 0; j < N; j++) { long key = random.nextLong(); // Ensure keys are uniques //key -= key % (threadIdx + 1); map.get(key); } })); final int threadIdx = i; futures.add(executor.submit(() -> { Random random = new Random(); for (int j = 0; j < N; j++) { long key = random.nextLong(); // Ensure keys are uniques key -= key % (threadIdx + 1); map.put(key, value); } })); } for (Future<?> future : futures) { future.get(); } assertEquals(map.size(), N * nThreads); } executor.shutdown(); } Most likely, npe would occur. The test may cost a long time to trigger the bug. Is it ok to run the test for such a long time in the junit test? > fix npe bug while getting element in the process of rehash > ---------------------------------------------------------- > > Key: ARTEMIS-1664 > URL: https://issues.apache.org/jira/browse/ARTEMIS-1664 > Project: ActiveMQ Artemis > Issue Type: Bug > Components: Broker > Affects Versions: 2.4.0 > Reporter: yangwei > Priority: Major > Fix For: 2.5.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)