use of reactor.core.publisher.FluxCreate.SerializedFluxSink in project reactor-core by reactor.
the class FluxCreateTest method serializedBufferSinkRaceNextCancel.
@Test
void serializedBufferSinkRaceNextCancel() {
AtomicInteger discarded = new AtomicInteger();
final Context context = Operators.discardLocalAdapter(String.class, s -> discarded.incrementAndGet()).apply(Context.empty());
BufferAsyncSink<String> baseSink = new BufferAsyncSink<>(new BaseSubscriber<String>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
// do not request
}
@Override
public Context currentContext() {
return context;
}
}, 10);
SerializedFluxSink<String> serializedSink = new SerializedFluxSink<>(baseSink);
RaceTestUtils.race(baseSink::cancel, () -> serializedSink.next("foo"));
assertThat(serializedSink.mpscQueue.poll()).as("serialized internal queue empty").isNull();
assertThat(baseSink.queue.poll()).as("bufferAsyncSink internal queue empty").isNull();
assertThat(discarded).as("discarded").hasValue(1);
}
Aggregations