You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2016/03/28 20:34:38 UTC

activemq git commit: https://issues.apache.org/jira/browse/AMQ-6210

Repository: activemq
Updated Branches:
  refs/heads/master 9a866cf56 -> f3ecc293f


https://issues.apache.org/jira/browse/AMQ-6210

Don't cache selectors for temp destinations.  

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

Branch: refs/heads/master
Commit: f3ecc293f023e2a75a2c243d361f7a3fc9800f67
Parents: 9a866cf
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Mar 28 14:34:20 2016 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Mar 28 14:34:20 2016 -0400

----------------------------------------------------------------------
 .../plugin/SubQueueSelectorCacheBroker.java     | 30 +++++++++-----------
 ...SubQueueSelectorCacheBrokerWildcardTest.java |  5 ++--
 2 files changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/f3ecc293/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java
----------------------------------------------------------------------
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 f6403eb..7b0e5ee 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
@@ -105,7 +105,6 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
             } catch (Exception e) {
                 LOG.warn("JMX is enabled, but when installing the VirtualDestinationSelectorCache, couldn't install the JMX mbeans. Continuing without installing the mbeans.");
             }
-
         }
     }
 
@@ -115,7 +114,7 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
         if (persistThread != null) {
             persistThread.interrupt();
             persistThread.join();
-        } //if
+        }
         unregisterMBeans();
     }
 
@@ -132,8 +131,8 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
 
     @Override
     public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
-        // don't track selectors for advisory topics
-        if (!AdvisorySupport.isAdvisoryTopic(info.getDestination())) {
+        // don't track selectors for advisory topics or temp destinations
+        if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) {
             String destinationName = info.getDestination().getQualifiedName();
             LOG.debug("Caching consumer selector [{}] on  '{}'", info.getSelector(), destinationName);
 
@@ -161,13 +160,11 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
                 LOG.debug("current selectors in cache: " + selectors);
                 subSelectorCache.put(destinationName, selectors);
             }
-
-
         }
+
         return super.addConsumer(context, info);
     }
 
-
     static boolean hasWildcards(String selector) {
         return WildcardFinder.hasWildcards(selector);
     }
@@ -189,6 +186,7 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
         super.removeConsumer(context, info);
     }
 
+    @SuppressWarnings("unchecked")
     private void readCache() {
         if (persistFile != null && persistFile.exists()) {
             try {
@@ -201,14 +199,14 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
                         LOG.error("Invalid selector cache data found. Please remove file.", ex);
                     } finally {
                         in.close();
-                    } //try
+                    }
                 } finally {
                     fis.close();
-                } //try
+                }
             } catch (IOException ex) {
                 LOG.error("Unable to read persisted selector cache...it will be ignored!", ex);
-            } //try
-        } //if
+            }
+        }
     }
 
     /**
@@ -225,15 +223,15 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
                 } finally {
                     out.flush();
                     out.close();
-                } //try
+                }
             } catch (IOException ex) {
                 LOG.error("Unable to persist selector cache", ex);
             } finally {
                 fos.close();
-            } //try
+            }
         } catch (IOException ex) {
             LOG.error("Unable to access file[{}]", persistFile, ex);
-        } //try
+        }
     }
 
     /**
@@ -254,7 +252,7 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
             try {
                 Thread.sleep(persistInterval);
             } catch (InterruptedException ex) {
-            } //try
+            }
 
             persistCache();
         }
@@ -268,6 +266,7 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
         this.singleSelectorPerDestination = singleSelectorPerDestination;
     }
 
+    @SuppressWarnings("unchecked")
     public Set<String> getSelectorsForDestination(String destinationName) {
         if (subSelectorCache.containsKey(destinationName)) {
             return new HashSet<String>(subSelectorCache.get(destinationName));
@@ -355,4 +354,3 @@ public class SubQueueSelectorCacheBroker extends BrokerFilter implements Runnabl
         }
     }
 }
-

http://git-wip-us.apache.org/repos/asf/activemq/blob/f3ecc293/activemq-broker/src/test/java/org/apache/activemq/plugin/SubQueueSelectorCacheBrokerWildcardTest.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/test/java/org/apache/activemq/plugin/SubQueueSelectorCacheBrokerWildcardTest.java b/activemq-broker/src/test/java/org/apache/activemq/plugin/SubQueueSelectorCacheBrokerWildcardTest.java
index bc9c357..771d57a 100644
--- a/activemq-broker/src/test/java/org/apache/activemq/plugin/SubQueueSelectorCacheBrokerWildcardTest.java
+++ b/activemq-broker/src/test/java/org/apache/activemq/plugin/SubQueueSelectorCacheBrokerWildcardTest.java
@@ -16,10 +16,9 @@
  */
 package org.apache.activemq.plugin;
 
-import org.junit.Test;
-
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
 
 /**
  * Tests that presence of wildcard characters is correctly identified by SubQueueSelectorCacheBroker