You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/03/23 20:55:51 UTC

[activemq-artemis] branch master updated: ARTEMIS-2667 NPE w/clearing non-durable dupl ID cache

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 402dda2  ARTEMIS-2667 NPE w/clearing non-durable dupl ID cache
     new 17e3b50  This closes #3034
402dda2 is described below

commit 402dda216187ec316b3bbe47f64509e270059a36
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Wed Mar 18 21:02:59 2020 -0500

    ARTEMIS-2667 NPE w/clearing non-durable dupl ID cache
---
 .../activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java    | 2 +-
 .../artemis/tests/integration/persistence/DuplicateCacheTest.java      | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java
index fff7e28..4446178 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/DuplicateIDCacheImpl.java
@@ -301,7 +301,7 @@ public class DuplicateIDCacheImpl implements DuplicateIDCache {
    public void clear() throws Exception {
       logger.debug("DuplicateIDCacheImpl(" + this.address + ")::clear removing duplicate ID data");
       synchronized (this) {
-         if (ids.size() > 0) {
+         if (ids.size() > 0 && persist) {
             long tx = storageManager.generateID();
             for (Pair<ByteArrayHolder, Long> id : ids) {
                storageManager.deleteDuplicateIDTransactional(tx, id.getB());
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
index 832bdfb..5951906 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/DuplicateCacheTest.java
@@ -95,6 +95,8 @@ public class DuplicateCacheTest extends StorageManagerTestBase {
       Assert.assertTrue(latch.await(1, TimeUnit.MINUTES));
 
       Assert.assertFalse(cache.contains(id));
+
+      cache.clear();
    }
 
    @Test
@@ -119,5 +121,6 @@ public class DuplicateCacheTest extends StorageManagerTestBase {
          cache.addToCache(bytes, null);
       }
 
+      cache.clear();
    }
 }