[KEYCLOAK-18117] - Unhandled exceptions not releasing worker thread
This commit is contained in:
parent
070c68e18a
commit
7d64637438
1 changed files with 14 additions and 3 deletions
|
@ -53,11 +53,10 @@ public class QuarkusRequestFilter extends AbstractRequestFilter implements Handl
|
||||||
// we need to close the session before response is sent to the client, otherwise subsequent requests could
|
// 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
|
// 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
|
// 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();
|
context.next();
|
||||||
promise.complete();
|
|
||||||
} catch (Throwable cause) {
|
} catch (Throwable cause) {
|
||||||
promise.fail(cause);
|
context.fail(cause);
|
||||||
// re-throw so that the any exception is handled from parent
|
// re-throw so that the any exception is handled from parent
|
||||||
throw new RuntimeException(cause);
|
throw new RuntimeException(cause);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +64,18 @@ public class QuarkusRequestFilter extends AbstractRequestFilter implements Handl
|
||||||
}, false, EMPTY_RESULT);
|
}, 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) {
|
private void configureContextualData(RoutingContext context, ClientConnection connection, KeycloakSession session) {
|
||||||
// quarkus-resteasy changed and clears the context map before dispatching
|
// quarkus-resteasy changed and clears the context map before dispatching
|
||||||
// need to push keycloak contextual objects into the routing context for retrieving it later
|
// need to push keycloak contextual objects into the routing context for retrieving it later
|
||||||
|
|
Loading…
Reference in a new issue