Skip to content

Commit

Permalink
[Core] Stop using PlaceHolderPublisher as subscribers cannot unsubscribe
Browse files Browse the repository at this point in the history
from it, which causes issues
  • Loading branch information
alexrobin committed Nov 17, 2023
1 parent 0e6d57a commit 3999873
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ public EventBus()
protected IEventPublisher ensurePublisher(final String topicID, final Supplier<IEventPublisher> supplier)
{
return publishers.compute(topicID, (id, pub) -> {
// if there is a placeholder, replace by actual publisher
boolean isPlaceHolder = pub instanceof PlaceHolderPublisher;
if (pub == null || isPlaceHolder)
if (pub == null)
{
log.debug("Creating publisher for {}", topicID);
IEventPublisher newPublisher = supplier.get();

if (isPlaceHolder)
((PlaceHolderPublisher)pub).transferTo(newPublisher);
var newPublisher = supplier.get();
return newPublisher;
}
else
Expand Down Expand Up @@ -153,7 +148,9 @@ public int getNumberOfSubscribers(String sourceID)
*/
synchronized void subscribe(String topicID, Subscriber<Event> subscriber)
{
IEventPublisher publisher = publishers.computeIfAbsent(topicID, id -> new PlaceHolderPublisher());
//IEventPublisher publisher = publishers.computeIfAbsent(topicID, id -> new PlaceHolderPublisher());
// don't use placeholder as it doesn't handle unsubscribe properly
var publisher = getPublisher(topicID);
publisher.subscribe(subscriber);
}

Expand Down

This file was deleted.

0 comments on commit 3999873

Please sign in to comment.