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