Skip to content

Commit

Permalink
ensures empty inner handled properly in case of sync fusion (#3307 fo…
Browse files Browse the repository at this point in the history
…llowup)

Signed-off-by: Oleh Dokuka <[email protected]>
  • Loading branch information
Oleh Dokuka committed Jan 11, 2023
1 parent 36fad66 commit 1d3a6f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ void drainSync() {
sp = iterable.spliterator();
itFinite = FluxIterable.checkFinite(sp);

isEmpty = itFinite && sp.estimateSize() == 0;

isEmpty = itFinite ? sp.estimateSize() == 0 : !hasNext(sp);
}
catch (Throwable exc) {
resetCurrent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,24 @@ public void testFluxIterableEmptyCase(Function<Flux, Flux> fn) {
.verify();
}

@ParameterizedTestWithName
@MethodSource("reactor.core.publisher.FluxIterableTest#factory")
public void testFluxIterableSyncFusionEmptyCase(Function<Flux, Flux> fn) {
Iterable<String> iterable = mock(Iterable.class);
Mockito.when(iterable.spliterator())
.thenReturn(mock(Spliterator.class));

StepVerifier.create(
Flux.just(1, 2)
.flatMapIterable(__ -> iterable)
.as(fn)
.next()
)
.expectSubscription()
.expectComplete()
.verify();
}

@ParameterizedTestWithName
@MethodSource("reactor.core.publisher.FluxIterableTest#factory")
public void testFluxIterableErrorHasNext(Function<Flux, Flux> fn) {
Expand Down

0 comments on commit 1d3a6f5

Please sign in to comment.