You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2015/08/19 16:14:28 UTC

activemq git commit: AMQ-5933 - add test and fix

Repository: activemq
Updated Branches:
  refs/heads/master 3ee84a17f -> 3c2ed9352


AMQ-5933 - add test and fix


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

Branch: refs/heads/master
Commit: 3c2ed9352b38f39ba57b322b9006ab82d7a4470f
Parents: 3ee84a1
Author: gtully <ga...@gmail.com>
Authored: Wed Aug 19 15:02:09 2015 +0100
Committer: gtully <ga...@gmail.com>
Committed: Wed Aug 19 15:02:41 2015 +0100

----------------------------------------------------------------------
 .../SelectorAwareVirtualTopicInterceptor.java     | 18 ++++++++++--------
 ...erVirtualTopicSelectorAwareForwardingTest.java | 17 +++++++++++++++++
 2 files changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/3c2ed935/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java
----------------------------------------------------------------------
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 b528f40..fdbfbe6 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
@@ -76,15 +76,17 @@ public class SelectorAwareVirtualTopicInterceptor extends VirtualTopicIntercepto
 
         if (cache != null) {
             final Set<String> selectors = cache.getSelector(dest.getActiveMQDestination().getQualifiedName());
-            for (String selector : selectors) {
-                try {
-                    final BooleanExpression expression = getExpression(selector);
-                    matches = expression.matches(msgContext);
-                    if (matches) {
-                        return true;
+            if (selectors != null) {
+                for (String selector : selectors) {
+                    try {
+                        final BooleanExpression expression = getExpression(selector);
+                        matches = expression.matches(msgContext);
+                        if (matches) {
+                            return true;
+                        }
+                    } catch (Exception e) {
+                        LOG.error(e.getMessage(), e);
                     }
-                } catch (Exception e) {
-                    LOG.error(e.getMessage(), e);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/activemq/blob/3c2ed935/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
index d1be900..697f55b 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerVirtualTopicSelectorAwareForwardingTest.java
@@ -578,6 +578,23 @@ public class TwoBrokerVirtualTopicSelectorAwareForwardingTest extends
 
     }
 
+    public void testSelectorNoMatchInCache() throws Exception {
+        clearSelectorCacheFiles();
+
+        // have the cache ignoreWildcardSelectors
+        final BrokerService brokerA = brokers.get("BrokerA").broker;
+        ((SubQueueSelectorCacheBrokerPlugin)brokerA.getPlugins()[0]).setIgnoreWildcardSelectors(true);
+
+        startAllBrokers();
+
+        ActiveMQDestination consumerBQueue = createDestination("Consumer.B.VirtualTopic.tempTopic", false);
+
+        MessageConsumer nonMatchingConsumer = createConsumer("BrokerA", consumerBQueue, "foo = 'bar%'");
+
+        ActiveMQTopic virtualTopic = new ActiveMQTopic("VirtualTopic.tempTopic");
+        sendMessages("BrokerA", virtualTopic, 1, asMap("foo", "notBar"));
+    }
+
     private HashMap<String, Object> asMap(String key, Object value) {
         HashMap<String, Object> rc = new HashMap<String, Object>(1);
         rc.put(key, value);