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