quarkusio/quarkus · error · IllegalStateException
OidcClient %s is closed
Error message
OidcClient %s is closed
What it means
OidcClientImpl.checkClosed throws IllegalStateException when any token operation (getTokens, refreshTokens, revokeAccessToken) is invoked after close() was called on the client. Once closed, the underlying HTTP client is shut down and the instance must not be reused.
Source
Thrown at extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java:473
MultiMap newMap = MultiMap.caseInsensitiveMultiMap();
newMap.addAll(oldMap);
return newMap;
}
@Override
public void close() throws IOException {
if (!closed) {
client.close();
if (clientAssertionProvider != null) {
clientAssertionProvider.close();
}
closed = true;
}
}
private void checkClosed() {
if (closed) {
throw new IllegalStateException("OidcClient " + oidcConfig.id().get() + " is closed");
}
}
private Uni<HttpRequest<Buffer>> filterHttpRequest(
OidcRequestContextProperties requestProps,
OidcEndpoint.Type endpointType, HttpRequest<Buffer> request, Buffer body) {
return OidcCommonUtils.filterHttpRequest(requestProps, request, body, requestFilters, endpointType);
}
private Uni<AsyncCredentials> withAsyncCredentials() {
if (clientAssertionProvider != null) {
return clientAssertionProvider.getClientAssertion().map(AsyncCredentials::new);
}
return AsyncCredentials.UNI_WITH_EMPTY_CREDENTIALS;
}
OidcClientConfig getConfig() {
return oidcConfig;View on GitHub (pinned to e1c734241f)
Solutions
- Stop using the closed client; obtain a fresh instance from OidcClients or OidcClientProvider
- Remove explicit close() calls unless the client lifecycle is fully owned by your code
- Check isClosed() / guard usage in long-lived components holding client references
- If lifecycle is managed by Quarkus (injected OidcClient), avoid closing it manually
Example fix
// before
oidcClient.close();
// ... later ...
Tokens t = oidcClient.getTokens().await().indefinitely(); // IllegalStateException
// after
if (!oidcClient.isClosed()) {
Tokens t = oidcClient.getTokens().await().indefinitely();
} Defensive patterns
Strategy: try-catch
Validate before calling
if (client.isClosed()) { client = recreateClient(); } Try / catch
try { return client.getTokens().await().indefinitely(); } catch (IllegalStateException e) { if (e.getMessage() != null && e.getMessage().endsWith("is closed")) { client = oidcClients.newClient(config).await().indefinitely(); return client.getTokens().await().indefinitely(); } throw e; } Prevention
- Do not call close() on injected, container-managed OidcClient instances
- Track client lifecycle in a scope that matches usage scope
- Re-acquire clients after shutdown/reload events
When it happens
Trigger: Calling getTokens(), awaitTokens(), refreshTokens(), or revokeAccessToken() on an OidcClient instance after close() — e.g. holding a stale reference after application shutdown, or reusing a client created in a scope that already closed it.
Common situations: Application shutdown hooks or request-scoped code calling close() then later code still using the injected/stored client; custom client management via OidcClientsImpl.newClient with manual lifecycle; hot redeployment scenarios where old references persist.
Related errors
- OIDC Client Registration is closed
- Registered OIDC Client is closed
- Client is closed
- Can only sync state on the server side of remote dev mode
- All parameters have already been loaded, it is too late to c
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/26322e4a8d2ff5e3.
Report an issue: GitHub.