{"record":{"id":"33846cf45b468fa7","repo":"quarkusio/quarkus","slug":"registered-oidc-client-is-closed","errorCode":null,"errorMessage":"Registered OIDC Client is closed","messagePattern":"Registered OIDC Client 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/RegisteredClientImpl.java","lineNumber":222,"sourceCode":"    }\n\n    private Uni<Void> deleteResponse(HttpResponse<Buffer> resp, OidcRequestContextProperties requestProps) {\n        return OidcCommonUtils.filterHttpResponse(requestProps, resp, responseFilters, OidcEndpoint.Type.REGISTERED_CLIENT)\n                .invoke(buffer -> {\n                    if (resp.statusCode() == 200) {\n                        LOG.debug(\"Client has been successfully deleted\");\n                    } else {\n                        String errorMessage = buffer.toString();\n                        LOG.debugf(\"Client delete request has failed:  status: %d, error message: %s\", resp.statusCode(),\n                                errorMessage);\n                    }\n                })\n                .replaceWithVoid();\n    }\n\n    private void checkClosed() {\n        if (closed) {\n            throw new IllegalStateException(\"Registered OIDC Client is closed\");\n        }\n    }\n\n    private void checkClientRequestUri() {\n        if (registrationClientUri == null) {\n            throw new OidcClientRegistrationException(\n                    \"Registered OIDC Client can not make requests to the client configuration endpoint\");\n        }\n    }\n\n    @Override\n    public String registrationUri() {\n        return this.registrationClientUri;\n    }\n\n    @Override\n    public String registrationToken() {\n        return this.registrationToken;","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/oidc-client-registration/runtime/src/main/java/io/quarkus/oidc/client/registration/runtime/RegisteredClientImpl.java#L204-L240","documentation":"Once a RegisteredClientImpl is closed (closed=true, via its close/delete lifecycle), all further API calls are rejected with IllegalStateException. checkClosed() is invoked by metadata(), read(), update(), and delete(), so any use of a closed client instance throws. This prevents requests on a client whose registration resources may have been released.","triggerScenarios":"Calling any method (metadata, read, update, delete) on a RegisteredClient instance after close() has been called on it, or on a client whose registration was deleted and marked closed.","commonSituations":"Application shutdown or context restart closes the client while background tasks still hold a reference; singleton beans reusing a closed instance after a re-registration; calling read/update after delete() on the same client.","solutions":["Obtain a fresh RegisteredClient from OidcClientRegistration (register() or registration client) instead of reusing the closed one","Re-order lifecycle logic so no calls happen after close(); guard background jobs with an is-closed check","If the client was deleted intentionally, stop using it rather than attempting further reads/updates"],"exampleFix":"// before\nregisteredClient.close();\nregisteredClient.read(); // IllegalStateException\n// after\nif (registeredClient != null) {\n    registeredClient.read();\n}\nregisteredClient.close();","handlingStrategy":"try-catch","validationCode":"if (registeredClient == null) {\n    throw new IllegalStateException(\"no registered client available\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    registeredClient.read();\n} catch (IllegalStateException e) {\n    // client closed: reacquire from OidcClientRegistration\n    registeredClient = registrationClient.register(metadata).await().indefinitely();\n}","preventionTips":["Close clients only at application shutdown, after all workers stop","Reacquire clients from the registration client instead of caching closed instances","Treat delete() as terminal for that instance"],"tags":["oidc","lifecycle","illegal-state"],"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"}