Skip to content

Commit

Permalink
fix:Adding two or more publishers is an error
Browse files Browse the repository at this point in the history
  • Loading branch information
zolmk committed Nov 2, 2023
1 parent 265bf6e commit 9c1f2f6
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import java.util.function.Supplier;

/**
* Unified event notify center.
Expand All @@ -43,7 +44,7 @@ public class NotifyCenter {

private DefaultSharePublisher sharePublisher;

private static EventPublisher eventPublisher = new DefaultPublisher();
private static final Supplier<EventPublisher> publisherSupplier = DefaultPublisher::new;

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

Expand All @@ -52,7 +53,7 @@ public class NotifyCenter {
static {
publisherFactory = (cls, buffer) -> {
try {
EventPublisher publisher = eventPublisher;
EventPublisher publisher = publisherSupplier.get();
publisher.init(cls, buffer);
return publisher;
} catch (Throwable ex) {
Expand Down

0 comments on commit 9c1f2f6

Please sign in to comment.