Skip to content

Commit a491ad7

Browse files
authored
Fix listener error (#1743)
1 parent 26249a2 commit a491ad7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mqtt-broker/src/main/java/io/streamnative/pulsar/handlers/mqtt/broker/impl/MQTTNamespaceBundleOwnershipListener.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.List;
1818
import java.util.stream.Collectors;
1919
import lombok.extern.slf4j.Slf4j;
20+
import org.apache.commons.collections4.CollectionUtils;
2021
import org.apache.pulsar.broker.namespace.NamespaceBundleOwnershipListener;
2122
import org.apache.pulsar.broker.namespace.NamespaceService;
2223
import org.apache.pulsar.common.naming.NamespaceBundle;
@@ -54,11 +55,13 @@ public void unLoad(NamespaceBundle bundle) {
5455
.collect(Collectors.toList()))
5556
.thenAccept(topics -> {
5657
log.info("unload namespace bundle : {}, topics : {}", bundle, topics);
57-
listeners.forEach(listener -> {
58-
if (listener.test(bundle.getNamespaceObject())) {
59-
topics.forEach(topic -> listener.unload(TopicName.get(topic)));
60-
}
61-
});
58+
if (CollectionUtils.isNotEmpty(listeners)) {
59+
listeners.forEach(listener -> {
60+
if (listener.test(bundle.getNamespaceObject())) {
61+
topics.forEach(topic -> listener.unload(TopicName.get(topic)));
62+
}
63+
});
64+
}
6265
}).exceptionally(ex -> {
6366
log.error("unload namespace bundle :{} error", bundle, ex);
6467
return null;

0 commit comments

Comments
 (0)