Skip to content

Commit 9c1f2f6

Browse files
author
zolmk
committed
fix:Adding two or more publishers is an error
1 parent 265bf6e commit 9c1f2f6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

threadpool/server/config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Map;
2929
import java.util.concurrent.ConcurrentHashMap;
3030
import java.util.function.BiFunction;
31+
import java.util.function.Supplier;
3132

3233
/**
3334
* Unified event notify center.
@@ -43,7 +44,7 @@ public class NotifyCenter {
4344

4445
private DefaultSharePublisher sharePublisher;
4546

46-
private static EventPublisher eventPublisher = new DefaultPublisher();
47+
private static final Supplier<EventPublisher> publisherSupplier = DefaultPublisher::new;
4748

4849
private static BiFunction<Class<? extends AbstractEvent>, Integer, EventPublisher> publisherFactory;
4950

@@ -52,7 +53,7 @@ public class NotifyCenter {
5253
static {
5354
publisherFactory = (cls, buffer) -> {
5455
try {
55-
EventPublisher publisher = eventPublisher;
56+
EventPublisher publisher = publisherSupplier.get();
5657
publisher.init(cls, buffer);
5758
return publisher;
5859
} catch (Throwable ex) {

0 commit comments

Comments
 (0)