Skip to content

Commit

Permalink
fix: replaced containsKey check with remove
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Peterson <[email protected]>
  • Loading branch information
mattp-swirldslabs committed Aug 4, 2024
1 parent d26b0ac commit 7066a7a
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,17 @@ public void subscribe(final EventHandler<ObjectEvent<SubscribeStreamResponse>> h
public void unsubscribe(final EventHandler<ObjectEvent<SubscribeStreamResponse>> handler) {

// Remove the subscriber
if (subscribers.containsKey(handler)) {
final var batchEventProcessor = subscribers.remove(handler);
if (batchEventProcessor == null) {
LOGGER.log(System.Logger.Level.ERROR, "Subscriber not found: {0}", handler);

final var batchEventProcessor = subscribers.remove(handler);
} else {

// Stop the processor
batchEventProcessor.halt();

// Remove the gating sequence from the ring buffer
ringBuffer.removeGatingSequence(batchEventProcessor.getSequence());

} else {
LOGGER.log(System.Logger.Level.ERROR, "Subscriber not found: {0}", handler);
}
}

Expand Down

0 comments on commit 7066a7a

Please sign in to comment.