You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2020/07/24 18:15:39 UTC

[activemq] branch master updated (6c0cb41 -> 62f5576)

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

cshannon pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/activemq.git.


    from 6c0cb41  AMQ-7516 - Fix XAConenctionPoolTest after change to make tmFromJndi an object
     add 300d0b9  Change org.apache.activemq.jms.pool.XaPooledConnectionFactory#tmFromJndi parameter to Boolean for JCA validation
     add 6c07033  AMQ-7516 - Fix XAConenctionPoolTest after change to make tmFromJndi an object
     new 083acb9  [AMQ-8012] Fix for ConcurrentModificationException in SubQueueSelectorCacheBroker
     new 1dcc7d4  Merge branch 'AMQ-8012'
     new 62f5576  AMQ-8012 - Improve thread safety of SubQueueSelectorCacheBroker

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../SelectorAwareVirtualTopicInterceptor.java      |  2 +-
 .../plugin/SubQueueSelectorCacheBroker.java        | 28 ++++++++--------------
 2 files changed, 11 insertions(+), 19 deletions(-)


[activemq] 01/03: [AMQ-8012] Fix for ConcurrentModificationException in SubQueueSelectorCacheBroker

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 083acb9691dba818aae3c0f72e7675c8a39d500a
Author: Matt Pavlovich <ma...@hyte.io>
AuthorDate: Fri Jul 24 12:22:12 2020 -0500

    [AMQ-8012] Fix for ConcurrentModificationException in SubQueueSelectorCacheBroker
    
     - Remove non-thread-safe method getSelectors()
     - Update all references to use the thread-safe getSelectorsForDestination() method
---
 .../region/virtual/SelectorAwareVirtualTopicInterceptor.java       | 2 +-
 .../org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java    | 7 -------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java
index d100c67..727f79d 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java
@@ -77,7 +77,7 @@ public class SelectorAwareVirtualTopicInterceptor extends VirtualTopicIntercepto
         LOG.debug("No active consumer match found. Will try cache if configured...");
 
         if (selectorCachePlugin != null) {
-            final Set<String> selectors = selectorCachePlugin.getSelector(dest.getActiveMQDestination().getQualifiedName());
+            final Set<String> selectors = selectorCachePlugin.getSelectorsForDestination(dest.getActiveMQDestination().getQualifiedName());
             if (selectors != null) {
                 for (String selector : selectors) {
                     try {
diff --git a/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java b/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
index 6147f4c..dbd9ad7 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
@@ -249,13 +249,6 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
     }
 
     /**
-     * @return The JMS selector for the specified {@code destination}
-     */
-    public Set<String> getSelector(final String destination) {
-        return subSelectorCache.get(destination);
-    }
-
-    /**
      * Persist the selector cache every {@code MAX_PERSIST_INTERVAL}ms.
      *
      * @see java.lang.Runnable#run()


[activemq] 02/03: Merge branch 'AMQ-8012'

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1dcc7d4b2c989c9efa03de42b169686b4c5eb8af
Merge: 6c0cb41 083acb9
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
AuthorDate: Fri Jul 24 14:13:45 2020 -0400

    Merge branch 'AMQ-8012'
    
    This closes #553

 .../region/virtual/SelectorAwareVirtualTopicInterceptor.java       | 2 +-
 .../org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java    | 7 -------
 2 files changed, 1 insertion(+), 8 deletions(-)


[activemq] 03/03: AMQ-8012 - Improve thread safety of SubQueueSelectorCacheBroker

Posted by cs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 62f5576fe5dc8bc06eefc1e26b8e66a10781fe32
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
AuthorDate: Fri Jul 24 14:15:57 2020 -0400

    AMQ-8012 - Improve thread safety of SubQueueSelectorCacheBroker
    
    When returning a copy of the set of selectors we need to synchronize
---
 .../plugin/SubQueueSelectorCacheBroker.java         | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java b/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
index dbd9ad7..0e48830 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
@@ -69,7 +69,7 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
      * The subscription's selector cache. We cache compiled expressions keyed
      * by the target destination.
      */
-    private ConcurrentMap<String, Set<String>> subSelectorCache = new ConcurrentHashMap<String, Set<String>>();
+    private ConcurrentMap<String, Set<String>> subSelectorCache = new ConcurrentHashMap<>();
 
     private final File persistFile;
     private boolean singleSelectorPerDestination = false;
@@ -275,8 +275,11 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
 
     @SuppressWarnings("unchecked")
     public Set<String> getSelectorsForDestination(String destinationName) {
-        if (subSelectorCache.containsKey(destinationName)) {
-            return new HashSet<String>(subSelectorCache.get(destinationName));
+        final Set<String> cachedSelectors = subSelectorCache.get(destinationName);
+        synchronized(cachedSelectors) {
+            if (cachedSelectors != null) {
+                return new HashSet<>(cachedSelectors);
+            }
         }
 
         return Collections.EMPTY_SET;
@@ -291,17 +294,13 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
     }
 
     public boolean deleteSelectorForDestination(String destinationName, String selector) {
-        if (subSelectorCache.containsKey(destinationName)) {
-            Set<String> cachedSelectors = subSelectorCache.get(destinationName);
-            return cachedSelectors.remove(selector);
-        }
-
-        return false;
+        final Set<String> cachedSelectors = subSelectorCache.get(destinationName);
+        return cachedSelectors != null ? cachedSelectors.remove(selector) : false;
     }
 
     public boolean deleteAllSelectorsForDestination(String destinationName) {
-        if (subSelectorCache.containsKey(destinationName)) {
-            Set<String> cachedSelectors = subSelectorCache.get(destinationName);
+        final Set<String> cachedSelectors = subSelectorCache.get(destinationName);
+        if (cachedSelectors != null) {
             cachedSelectors.clear();
         }
         return true;