Skip to content

Commit

Permalink
Allow empty response when an exception is thrown (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
andriy-dmytruk authored Jun 16, 2024
1 parent c788d0a commit 56776af
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,16 @@ public void service(ServletExchange<REQ, RES> exchange) {
if (exchange.getRequest().isAsyncSupported()) {
exchange.getRequest().executeAsync(asyncExecution -> {
try (PropagatedContext.Scope ignore = PropagatedContext.getOrEmpty().plus(new ServerHttpRequestContext(req)).propagate()) {
lc.handleNormal(req)
.onComplete((response, throwable) -> onComplete(exchange, req, response.toMutableResponse(), throwable, httpResponse -> {
asyncExecution.complete();
requestTerminated.accept(httpResponse);
}));
lc.handleNormal(req).onComplete((response, throwable) -> onComplete(
exchange,
req,
response == null ? null : response.toMutableResponse(),
throwable,
httpResponse -> {
asyncExecution.complete();
requestTerminated.accept(httpResponse);
}
));
}
});
} else {
Expand All @@ -228,7 +233,13 @@ public void service(ServletExchange<REQ, RES> exchange) {
lc.handleNormal(req)
.onComplete((response, throwable) -> {
try {
onComplete(exchange, req, response.toMutableResponse(), throwable, requestTerminated);
onComplete(
exchange,
req,
response == null ? null : response.toMutableResponse(),
throwable,
requestTerminated
);
} finally {
termination.complete(null);
}
Expand Down

0 comments on commit 56776af

Please sign in to comment.