The PR changed a small notification delivery node for the internal operations panel. After the update, unstable symptoms appeared under load: some subscribers sometimes receive the same message twice, and the process does not always terminate on its own after the scenario finishes. A review of the diff is needed to find the real defects.
Context and requirements:
javac src/*.java && java -cp src Demo.subscribe(String channel, Subscriber subscriber) registers a subscriber for a channel.unsubscribe(String channel, Subscriber subscriber) removes the subscription.publish(String channel, String message) schedules delivery to all subscribers that were in the channel at the moment of the call.close() must release the instance’s background resources.channel, message, and subscriber are not null.subscribe, unsubscribe, and publish at the same time.Subscriber instances representing the same recipient may be different objects, but with the same id().What needs to be done in the review:
The files below show the state before and after the PR.
Java 21 (Temurin/OpenJDK 21), no external dependencies. Reproduction commands: javac src/*.java and java -cp src Demo. Any OS with the standard Java runtime available. No additional infrastructure, test framework, or third-party libraries.
Use line comments to explain the problem, its impact, the fix and how to test it.