{"record":{"id":"e3c8a7b7c036fe3a","repo":"quarkusio/quarkus","slug":"oidc-client-registration-is-closed","errorCode":null,"errorMessage":"OIDC Client Registration is closed","messagePattern":"OIDC Client Registration is closed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/oidc-client-registration/runtime/src/main/java/io/quarkus/oidc/client/registration/runtime/OidcClientRegistrationImpl.java","lineNumber":234,"sourceCode":"                requestFilters, responseFilters, createMetadata(oidcConfig.metadata()), registrationUri, registrationToken);\n        return newClient.read();\n    }\n\n    @Override\n    public void close() throws IOException {\n        if (!closed) {\n            try {\n                client.close();\n            } catch (Exception ex) {\n                LOG.debug(\"Failed to close the client\", ex);\n            }\n            closed = true;\n        }\n    }\n\n    private void checkClosed() {\n        if (closed) {\n            throw new IllegalStateException(\"OIDC Client Registration is closed\");\n        }\n    }\n\n    static class ClientRegistrationHelper {\n        RegisteredClient client;\n        String registrationUri;\n\n        ClientRegistrationHelper(RegisteredClient client, String registrationUri) {\n            this.client = client;\n            this.registrationUri = registrationUri;\n        }\n    }\n\n    static ClientMetadata createMetadata(Metadata metadata) {\n        JsonObjectBuilder json = jsonProvider().createObjectBuilder();\n        if (metadata.clientName().isPresent()) {\n            json.add(OidcConstants.CLIENT_METADATA_CLIENT_NAME, metadata.clientName().get());\n        }","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/oidc-client-registration/runtime/src/main/java/io/quarkus/oidc/client/registration/runtime/OidcClientRegistrationImpl.java#L216-L252","documentation":"OidcClientRegistrationImpl.checkClosed throws IllegalStateException once close() has been called on the registration client. After closing, all operations (registerClient, registerClients, registeredClient, readClient) are rejected because the underlying resources were released. This is a lifecycle misuse error, not a server-side problem.","triggerScenarios":"Calling registerClient(...) or registerClients(...) on an OidcClientRegistration instance after invoking close() on it — e.g. using a client obtained from a different lifecycle scope than the one that closed it.","commonSituations":"Application shutdown hooks closing the registration client while background tasks still register clients; calling close() in a finally block then retrying; reusing a request-scoped closed client.","solutions":["Do not call close() until all registration operations are complete","Obtain a fresh OidcClientRegistration instance from the recorder/CDI instead of reusing a closed one","Guard long-running registration tasks with a check that the client is still open"],"exampleFix":"// before\nclient.close();\nclient.registerClient(metadata); // IllegalStateException\n// after\nclient.registerClient(metadata);\nclient.close(); // close only after all operations","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    client.registerClient(metadata).await().indefinitely();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"is closed\")) {\n        client = oidcClientRegistrations.get(name); // re-acquire\n    } else throw e;\n}","preventionTips":["Close registration clients only in shutdown hooks after all work finishes","Track client lifecycle with reference counting","Re-acquire a fresh instance instead of reusing closed ones"],"tags":["oidc","lifecycle","illegal-state"],"backgroundTag":"resource-already-closed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}