{"record":{"id":"26322e4a8d2ff5e3","repo":"quarkusio/quarkus","slug":"oidcclient-s-is-closed","errorCode":null,"errorMessage":"OidcClient %s is closed","messagePattern":"OidcClient (.+?) is closed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java","lineNumber":473,"sourceCode":"        MultiMap newMap = MultiMap.caseInsensitiveMultiMap();\n        newMap.addAll(oldMap);\n        return newMap;\n    }\n\n    @Override\n    public void close() throws IOException {\n        if (!closed) {\n            client.close();\n            if (clientAssertionProvider != null) {\n                clientAssertionProvider.close();\n            }\n            closed = true;\n        }\n    }\n\n    private void checkClosed() {\n        if (closed) {\n            throw new IllegalStateException(\"OidcClient \" + oidcConfig.id().get() + \" is closed\");\n        }\n    }\n\n    private Uni<HttpRequest<Buffer>> filterHttpRequest(\n            OidcRequestContextProperties requestProps,\n            OidcEndpoint.Type endpointType, HttpRequest<Buffer> request, Buffer body) {\n        return OidcCommonUtils.filterHttpRequest(requestProps, request, body, requestFilters, endpointType);\n    }\n\n    private Uni<AsyncCredentials> withAsyncCredentials() {\n        if (clientAssertionProvider != null) {\n            return clientAssertionProvider.getClientAssertion().map(AsyncCredentials::new);\n        }\n        return AsyncCredentials.UNI_WITH_EMPTY_CREDENTIALS;\n    }\n\n    OidcClientConfig getConfig() {\n        return oidcConfig;","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java#L455-L491","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\noidcClient.close();\n// ... later ...\nTokens t = oidcClient.getTokens().await().indefinitely(); // IllegalStateException\n\n// after\nif (!oidcClient.isClosed()) {\n    Tokens t = oidcClient.getTokens().await().indefinitely();\n}","handlingStrategy":"try-catch","validationCode":"if (client.isClosed()) { client = recreateClient(); }","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["lifecycle","closed-resource","oidc"],"backgroundTag":"client-already-closed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}