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

RxJava3Adapter.singleToMono() doesn't cascade dispose() calls up the chain to the RxJava disposable #291

Open
adammilnesmith opened this issue Feb 28, 2023 · 0 comments
Labels
❓need-triage This issue needs triage, hasn't been looked at by a team member yet

Comments

@adammilnesmith
Copy link

RxJava3Adapter.singleToMono() doesn't cascade dispose() calls up the chain to the RxJava disposable.

Expected Behavior

dispose() calls should cascade up the chain to the RxJava Single disposable.

Actual Behavior

dispose() calls are not cascaded up the chain to the RxJava Single disposable.

Steps to Reproduce

This test will fail for singleToMono:

@Test
public void singleToMonoCancel() {
	final AtomicBoolean disposeWasCalled = new AtomicBoolean(false);
	Mono<Integer> m = Single.<Integer>never()
			.doOnDispose(() -> disposeWasCalled.set(true))
			.to(RxJava3Adapter::singleToMono);
	m.subscribe().dispose();
	assertTrue(disposeWasCalled.get());
}

It's worth noting that this passes for maybeToMono:

@Test
public void maybeToMonoCancel() {
	final AtomicBoolean disposeWasCalled = new AtomicBoolean(false);
	Mono<Integer> m = Maybe.<Integer>never()
			.doOnDispose(() -> disposeWasCalled.set(true))
			.to(RxJava3Adapter::maybeToMono);
	m.subscribe().dispose();
	assertTrue(disposeWasCalled.get());
}

Possible Solution

Add the following to SingleAsMonoSubscriber matching MaybeAsMonoObserver

            @Override
            public void cancel() {
                super.cancel();
                d.dispose();
            }

Your Environment

  • Reactor version(s) used: v3.5.0
  • Other relevant libraries versions: RxJava 2 and 3
@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓need-triage This issue needs triage, hasn't been looked at by a team member yet
Projects
None yet
Development

No branches or pull requests

2 participants