Skip to content

Commit

Permalink
Fix #508 FlattenIterableSubscriber.isEmpty check (#509)
Browse files Browse the repository at this point in the history
- returned true from isEmpty when iterator had more elements
  • Loading branch information
lhotari authored and smaldini committed Apr 1, 2017
1 parent 575de72 commit ab79b24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ public void clear() {
public boolean isEmpty() {
Iterator<? extends R> it = current;
if (it != null) {
return it.hasNext();
return !it.hasNext();
}
return queue.isEmpty(); // estimate
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/reactor/core/publisher/FluxFlattenIterableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,18 @@ public void testDrainAsyncCompletesSeveralBatches() {
.verifyComplete();
}

/**
* See https://github.com/reactor/reactor-core/issues/508
*/
@Test
public void testPublishingTwice() {
StepVerifier.create(Flux.just(Flux.range(0, 300).toIterable(), Flux.range(0, 300).toIterable())
.flatMapIterable(x -> x)
.share()
.share()
.count())
.expectNext(600L)
.verifyComplete();
}

}

0 comments on commit ab79b24

Please sign in to comment.