Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flatMapIterable stops emmitting when published twice #508

Closed
lbovet opened this issue Apr 1, 2017 · 3 comments
Closed

flatMapIterable stops emmitting when published twice #508

lbovet opened this issue Apr 1, 2017 · 3 comments

Comments

@lbovet
Copy link

lbovet commented Apr 1, 2017

The following code should issue 600

    just(range(0, 300).toIterable(), range(0, 300).toIterable())
            .flatMapIterable(x->x)
            .share()
            .share()
            .count()
            .log()
            .subscribe();

But it issues 256

Whereas

    just(range(0, 300).toIterable(), range(0, 300).toIterable())
            .flatMap(Flux::fromIterable)
            .share()
            .share()
            .count()
            .log()
            .subscribe();

works as expected

Note: I could produce the wrong behaviour only with multiple iterables in the "just" and publishing twice.

@lhotari
Copy link
Contributor

lhotari commented Apr 1, 2017

Failing test:

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

Passes with this modification:

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

@lhotari
Copy link
Contributor

lhotari commented Apr 1, 2017

lhotari added a commit to lhotari/reactor-core that referenced this issue Apr 1, 2017
- returned true from isEmpty when iterator had more elements
@lhotari
Copy link
Contributor

lhotari commented Apr 1, 2017

I made PR #509 with a fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants