Skip to content

Commit

Permalink
[KEYCLOAK-18117] - Unhandled exceptions not releasing worker thread
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroigor authored and mposolda committed Jun 10, 2021
1 parent 070c68e commit 7d64637
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,29 @@ public void handle(RoutingContext context) {
// we need to close the session before response is sent to the client, otherwise subsequent requests could
// not get the latest state because the session from the previous request is still being closed
// other methods from Vert.x to add a handler to the response works asynchronously
context.addHeadersEndHandler(event -> close(session));
context.addHeadersEndHandler(createEndHandler(context, promise, session));
context.next();
promise.complete();
} catch (Throwable cause) {
promise.fail(cause);
context.fail(cause);
// re-throw so that the any exception is handled from parent
throw new RuntimeException(cause);
}
});
}, false, EMPTY_RESULT);
}

private Handler<Void> createEndHandler(RoutingContext context, io.vertx.core.Promise<Object> promise,
KeycloakSession session) {
return event -> {
try {
close(session);
promise.complete();
} catch (Throwable cause) {
context.fail(cause);
}
};
}

private void configureContextualData(RoutingContext context, ClientConnection connection, KeycloakSession session) {
// quarkus-resteasy changed and clears the context map before dispatching
// need to push keycloak contextual objects into the routing context for retrieving it later
Expand Down

0 comments on commit 7d64637

Please sign in to comment.