mirror of https://github.com/apache/activemq.git
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 8e2176d93c
)
This commit is contained in:
parent
7eb1425733
commit
bf35f42bb6
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.filter;
|
package org.apache.activemq.filter;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -201,12 +202,18 @@ public class DestinationMap {
|
||||||
* @return the largest matching value or null if no value matches
|
* @return the largest matching value or null if no value matches
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public Object chooseValue(ActiveMQDestination destination) {
|
public Object chooseValue(final ActiveMQDestination destination) {
|
||||||
Set set = get(destination);
|
Set set = get(destination);
|
||||||
if (set == null || set.isEmpty()) {
|
if (set == null || set.isEmpty()) {
|
||||||
return null;
|
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();
|
return sortedSet.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue