activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject [2/2] git commit: Fix for https://issues.apache.org/jira/browse/AMQ-4884
Date Thu, 14 Nov 2013 09:49:03 GMT
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/0a67b12c
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/0a67b12c
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/0a67b12c

Branch: refs/heads/trunk
Commit: 0a67b12c647bc3fb42542b640dfb698fcf802456
Parents: 291ec5e
Author: rajdavies <rajdavies@gmail.com>
Authored: Thu Nov 14 09:48:34 2013 +0000
Committer: rajdavies <rajdavies@gmail.com>
Committed: Thu Nov 14 09:48:34 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/0a67b12c/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);
     }


Mime
View raw message