activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6109
Date Tue, 29 Dec 2015 12:49:08 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.12.x 7eb142573 -> bf35f42bb


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

The chooseValue method in DestinationMap will now always return the
exact match, if there is one, else it will then sort as before.

(cherry picked from commit 8e2176d93c95d847c813f54d54aaf9bafba4d5c4)


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

Branch: refs/heads/activemq-5.12.x
Commit: bf35f42bb69e57d5aebdb4f2afc95f544fb1edb5
Parents: 7eb1425
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Mon Dec 28 16:40:10 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Tue Dec 29 12:48:08 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/activemq/filter/DestinationMap.java  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/bf35f42b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
index fd07b7a..b361203 100755
--- a/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
+++ b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.filter;
 
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -201,12 +202,18 @@ public class DestinationMap {
      * @return the largest matching value or null if no value matches
      */
     @SuppressWarnings({"rawtypes", "unchecked"})
-    public Object chooseValue(ActiveMQDestination destination) {
+    public Object chooseValue(final ActiveMQDestination destination) {
         Set set = get(destination);
         if (set == null || set.isEmpty()) {
             return null;
         }
-        SortedSet sortedSet = new TreeSet(set);
+        SortedSet sortedSet = new TreeSet(new Comparator<DestinationMapEntry>() {
+            @Override
+            public int compare(DestinationMapEntry entry1, DestinationMapEntry entry2) {
+                return destination.equals(entry1.destination) ? -1 : (destination.equals(entry2.destination)
? 1 : entry1.compareTo(entry2));
+            }
+        });
+        sortedSet.addAll(set);
         return sortedSet.first();
     }
 


Mime
View raw message