Skip to content

Commit

Permalink
Make use of CompletionStage#handle instead of whenComplete (#3221)
Browse files Browse the repository at this point in the history
This commit improves `MonoCompletionStage` performance by using handle
instead of whenComplete. The later notably seems to create unnecessary
`CompletionException`.
  • Loading branch information
He-Pin committed Oct 10, 2022
1 parent 00dbb17 commit f160733
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void cancel() {
return;
}

future.whenComplete((v, e) -> {
future.handle((v, e) -> {
if (sds.isCancelled()) {
//nobody is interested in the Mono anymore, don't risk dropping errors
Context ctx = sds.currentContext();
Expand All @@ -79,7 +79,7 @@ public void cancel() {
Operators.onDiscard(v, ctx);
}

return;
return null;
}
try {
if (e instanceof CompletionException) {
Expand All @@ -99,6 +99,7 @@ else if (v != null) {
Operators.onErrorDropped(e1, actual.currentContext());
throw Exceptions.bubble(e1);
}
return null;
});
}

Expand Down

0 comments on commit f160733

Please sign in to comment.