diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java index a7613ef2d1..ecf6cf75d0 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationFilter.java @@ -389,12 +389,11 @@ public class DestinationFilter implements Destination { } public void deleteSubscription(ConnectionContext context, SubscriptionKey key) throws Exception { - Destination target = next; - while (target instanceof DestinationFilter) { - target = ((DestinationFilter) target).next; - } - if (target instanceof Topic) { - Topic topic = (Topic)target; + if (next instanceof DestinationFilter) { + DestinationFilter filter = (DestinationFilter) next; + filter.deleteSubscription(context, key); + } else if (next instanceof Topic) { + Topic topic = (Topic)next; topic.deleteSubscription(context, key); } }