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

Ensure atomic cleanup in Flux/Mono.usingWhen(…) #1486

Closed
mp911de opened this issue Jan 11, 2019 · 0 comments
Closed

Ensure atomic cleanup in Flux/Mono.usingWhen(…) #1486

mp911de opened this issue Jan 11, 2019 · 0 comments
Assignees
Labels
type/bug A general bug
Milestone

Comments

@mp911de
Copy link

mp911de commented Jan 11, 2019

Expected behavior

Cleanup functions should be called only once.

Actual behavior

Cleanup close can be called multiple times if a subscription terminates and then gets cancelled.

Steps to reproduce

Publisher<Void> cleanup = …,
Flux flux = Flux.usingWhen(…, cleanup, cleanup, cleanup);

flux.subscribe(new CoreSubscriber<Object>() {
	Subscription subscription;

	@Override
	public void onSubscribe(Subscription s) {
		s.request(1);
		subscription = s;
	}

	@Override
	public void onNext(Object o) {}

	@Override
	public void onError(Throwable t) {}

	@Override
	public void onComplete() {
		subscription.cancel();
	}
});

Reactor Core version

Reactor 3.2.5

mp911de added a commit to spring-projects/spring-data-r2dbc that referenced this issue Jan 11, 2019
We now make sure to close connections only once by tracking the cleanup state. Flux.usingWhen/Mono.usingWhen do not ensure atomic cleanup in situations where the subscription completes and then the subscription is terminated.

This behavior has lead to closing a connection multiple times.

Related ticket: reactor/reactor-core#1486
simonbasle added a commit that referenced this issue Jan 11, 2019
This commit prevents asyncComplete/asyncError terminal callbacks to
apply in addition to asyncCancel, in case one signal is still received
after the other (eg. a cancellation is performed asynchronously,
resulting in the signal arriving AFTER the onError/onComplete signals).
@simonbasle simonbasle self-assigned this Jan 11, 2019
@simonbasle simonbasle added the type/bug A general bug label Jan 11, 2019
@simonbasle simonbasle added this to the 3.2.6.RELEASE milestone Jan 11, 2019
bsideup pushed a commit that referenced this issue Jan 28, 2019
…#1487)

This commit prevents asyncComplete/asyncError terminal callbacks to
apply in addition to asyncCancel, in case one signal is still received
after the other (eg. a cancellation is performed asynchronously,
resulting in the signal arriving AFTER the onError/onComplete signals).
loob2dev pushed a commit to loob2dev/spring-r2dbc that referenced this issue Apr 3, 2021
We now make sure to close connections only once by tracking the cleanup state. Flux.usingWhen/Mono.usingWhen do not ensure atomic cleanup in situations where the subscription completes and then the subscription is terminated.

This behavior has lead to closing a connection multiple times.

Related ticket: reactor/reactor-core#1486
rayrobert398 added a commit to rayrobert398/spring-data-Mobile-App-Developer-Java that referenced this issue Oct 3, 2022
We now make sure to close connections only once by tracking the cleanup state. Flux.usingWhen/Mono.usingWhen do not ensure atomic cleanup in situations where the subscription completes and then the subscription is terminated.

This behavior has lead to closing a connection multiple times.

Related ticket: reactor/reactor-core#1486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants