Repository: activemq Updated Branches: refs/heads/activemq-5.12.x 9ecef371a -> e546d2999
AMQ-5933 - add test and fix (cherry picked from commit 3c2ed9352b38f39ba57b322b9006ab82d7a4470f) Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/e546d299 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/e546d299 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/e546d299 Branch: refs/heads/activemq-5.12.x Commit: e546d299972fd2a4e7c72d18f62781d372a78f28 Parents: 9ecef37 Author: gtully <[email protected]> Authored: Wed Aug 19 15:02:09 2015 +0100 Committer: Timothy Bish <[email protected]> Committed: Wed Aug 19 11:23:21 2015 -0400 ---------------------------------------------------------------------- .../SelectorAwareVirtualTopicInterceptor.java | 18 ++++++++++-------- ...erVirtualTopicSelectorAwareForwardingTest.java | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/e546d299/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/e546d299/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);
