Fix for https://issues.apache.org/jira/browse/AMQ-4884


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

Branch: refs/heads/activemq-5.9
Commit: a2e126deb144757678b3e12f1d4ecf9db96d4acd
Parents: 22fe626
Author: rajdavies <[email protected]>
Authored: Thu Nov 14 09:48:34 2013 +0000
Committer: Hadrian Zbarcea <[email protected]>
Committed: Wed Mar 12 12:06:11 2014 -0400

----------------------------------------------------------------------
 .../filter/PrefixDestinationFilter.java         | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/a2e126de/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java
----------------------------------------------------------------------
diff --git 
a/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java
 
b/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java
index abe7530..5f9b6bc 100755
--- 
a/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java
+++ 
b/activemq-client/src/main/java/org/apache/activemq/filter/PrefixDestinationFilter.java
@@ -40,22 +40,40 @@ public class PrefixDestinationFilter extends 
DestinationFilter {
         this.destinationType = destinationType;
     }
 
+
     public boolean matches(ActiveMQDestination destination) {
-       if (destination.getDestinationType() != destinationType) return false;
+        if (destination.getDestinationType() != destinationType) return false;
         String[] path = 
DestinationPath.getDestinationPaths(destination.getPhysicalName());
+
+
         int length = prefixes.length;
         if (path.length >= length) {
             int size = length - 1;
             for (int i = 0; i < size; i++) {
-                if (!path[i].equals(ANY_CHILD) && 
!prefixes[i].equals(ANY_CHILD) && !prefixes[i].equals(path[i])) {
+                if (!matches(prefixes[i],path[i])) {
                     return false;
                 }
             }
             return true;
+        }else{
+            //want to look for the case where A matches A.>
+            boolean match = true;
+            for (int i = 0; (i < path.length && match); i++){
+                   match &= matches(prefixes[i],path[i]);
+            }
+            //paths get compacted - e.g. A.*.> will be compacted to A.> and by 
definition - the last element on
+            //the prefix will be >
+            if (match && prefixes.length == (path.length + 1)){
+                return true;
+            }
         }
         return false;
     }
 
+    private boolean matches(String prefix,String path){
+        return path.equals(ANY_CHILD) || prefix.equals(ANY_CHILD) || 
prefix.equals(path);
+    }
+
     public String getText() {
         return DestinationPath.toString(prefixes);
     }

Reply via email to