Repository navigation
Ignore wrapped CancellationException after fromFuture cancel - #4425
Open
akashchamp wants to merge 1 commit into
Open
akashchamp wants to merge 1 commit into
akashchamp wants to merge 1 commit into
Conversation
When the Mono is cancelled, MonoCompletionStage ignores a late CancellationException from the future but sends any other error to onErrorDropped. A cancelled future can also fail with a CompletionException wrapping the CancellationException, for instance a dependent stage of a cancelled CompletableFuture, or the future returned by java.net.http.HttpClient.sendAsync. That case was logged as a dropped error even though the Mono requested the cancellation. Unwrap a CompletionException before checking for cancellation, so it is ignored the same way. Fixes reactor#4415. Signed-off-by: Akash Kumar <116457960+akashchamp@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cancelling a
Mono.fromFuture(...)no longer logs anOperator called default onErrorDroppederror when the future then fails with aCompletionExceptionthat wraps aCancellationException. That happens with a dependent stage of a cancelledCompletableFuture, or withHttpClient.sendAsync.MonoCompletionStageSubscriptionalready ignored a plainCancellationExceptionafter cancellation. It now unwraps aCompletionExceptionbefore that check. Any other late failure, wrapped or not, still goes toonErrorDroppedas before.I added the two reproducers from the issue as tests in
MonoCompletionStageTest, plus one checking that a wrapped non-cancellation error is still dropped. Without the fix, the two new cancellation tests fail with the droppedCompletionException: CancellationException. With it,MonoCompletionStageTest, thereactor.core.publisher.Mono*tests (1201 run, 0 failed) andspotlessCheckpass. I also ran the issue's snippet against the built classes on JDK 8: before the fix it printed twoDROPPEDlines, and after the fix it prints none for the cancellations.I targeted
mainbecause the issue has no milestone and 3.8.8 is the only open one. Happy to retarget if this should go to a maintenance branch.Fixes #4415.