{"record":{"id":"d0a8674fb9c3bba7","repo":"apache/iceberg","slug":"failed-to-close-the-oauth2refreshcredentialshandle","errorCode":null,"errorMessage":"Failed to close the OAuth2RefreshCredentialsHandler","messagePattern":"Failed to close the OAuth2RefreshCredentialsHandler","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"warning","filePath":"gcp/src/main/java/org/apache/iceberg/gcp/gcs/OAuth2RefreshCredentialsHandler.java","lineNumber":142,"sourceCode":"          client = httpClient.withAuthSession(authSession);\n        }\n      }\n    }\n\n    return client;\n  }\n\n  @Override\n  public void close() {\n    CloseableGroup closeableGroup = new CloseableGroup();\n    closeableGroup.addCloseable(authSession);\n    closeableGroup.addCloseable(authManager);\n    closeableGroup.addCloseable(client);\n    closeableGroup.setSuppressCloseFailure(true);\n    try {\n      closeableGroup.close();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to close the OAuth2RefreshCredentialsHandler\", e);\n    }\n  }\n}\n","sourceCodeStart":124,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/gcp/src/main/java/org/apache/iceberg/gcp/gcs/OAuth2RefreshCredentialsHandler.java#L124-L146","documentation":"OAuth2RefreshCredentialsHandler.close() wraps IOException raised while closing its CloseableGroup (authManager and REST client) into UncheckedIOException. It indicates cleanup of the OAuth2 credential-refresh machinery failed, typically an error shutting down the HTTP client or auth manager.","triggerScenarios":"Calling close() on OAuth2RefreshCredentialsHandler when the underlying REST client or AuthManager throws IOException during shutdown.","commonSituations":"Client already closed; underlying HTTP connection in a broken state; failures during token revocation on close.","solutions":["Inspect the chained IOException cause; close-failures are often benign resource leaks","Ensure close() is called once (use try-with-resources)","Upgrade/verify REST client and auth manager versions for known close bugs","Log and continue if the failure is only cleanup-related"],"exampleFix":"// before\nhandler.close();\n// after\ntry (OAuth2RefreshCredentialsHandler handler = ...) {\n  // use handler\n} // close failures are reported, not masking real errors (suppressCloseFailure=true)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (OAuth2RefreshCredentialsHandler h = ...) { /* use */ } catch (UncheckedIOException e) { LOG.warn(\"Cleanup failure\", e.getCause()); }","preventionTips":["Use try-with-resources so close() runs once","Treat close failures as cleanup warnings, not data loss","Keep REST/auth client versions current"],"tags":["gcs","oauth2","resource-cleanup"],"backgroundTag":"file-write-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}