-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Description
It seems that something is being sent after the response is sent with Context.send() in CompletionStage.
Can the process here in io.jooby.internal.handler.apply() be changed?
} else if (result instanceof CompletionStage future) {
future.whenComplete(
(value, x) -> {
// Add the following if statement
if (ctx.isResponseStarted()) {
return;
}
try {
Route.After after = ctx.getRoute().getAfter();
if (after != null) {
// run after:
after.apply(ctx, value, unwrap((Throwable) x));
}
if (x != null) {
Throwable exception = unwrap((Throwable) x);
ctx.sendError(exception);
} else {
ctx.render(value);
}
} catch (Throwable cause) {
ctx.sendError(cause);
}
});
// Return context to mark as handled
return ctx;
}