When I unsubscribe the last Sub and sub again, I expect the Sink/Flux to work or throw an Exception.
See my Testcode:
void playground() {
Sinks.Many<String> sink = Sinks.many().multicast().onBackpressureBuffer();
var disposer = sink.asFlux().subscribe(s -> System.out.println("1: "+s));
System.out.println("CurrentSubs:" + sink.currentSubscriberCount());
sink.tryEmitNext("Test1");
var disposer2 = sink.asFlux().subscribe(s -> System.out.println("2: "+s));
System.out.println("CurrentSubs:" + sink.currentSubscriberCount());
sink.tryEmitNext("Test2");
disposer.dispose();
System.out.println("CurrentSubs:" + sink.currentSubscriberCount());
sink.tryEmitNext("Test3");
disposer2.dispose();
System.out.println("CurrentSubs:" + sink.currentSubscriberCount());
var disposer3 = sink.asFlux().subscribe(s -> System.out.println("3: "+s));
System.out.println("CurrentSubs:" + sink.currentSubscriberCount());
sink.tryEmitNext("Test4");
disposer3.dispose();
System.out.println("CurrentSubs:" + sink.currentSubscriberCount());
}
And the Output:
1: Test1
CurrentSubs:2
1: Test2
2: Test2
CurrentSubs:1
2: Test3
CurrentSubs:0
CurrentSubs:0
CurrentSubs:0
This behaviour seems weird to me, I would at least expect an Exception when I try to sub again and fail.
Is there any reason behind this behaviour.