{"record":{"id":"17cd5696bc2cbb52","repo":"apache/iceberg","slug":"failed-to-close-http-client","errorCode":null,"errorMessage":"Failed to close HTTP client","messagePattern":"Failed to close HTTP client","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java","lineNumber":212,"sourceCode":"  @Override\n  public void initialize(String name, Map<String, String> unresolved) {\n    Preconditions.checkArgument(unresolved != null, \"Invalid configuration: null\");\n    // resolve any configuration that is supplied by environment variables\n    // note that this is only done for local config properties and not for properties from the\n    // catalog service\n    Map<String, String> props = EnvironmentUtil.resolveAll(unresolved);\n\n    this.closeables = new CloseableGroup();\n\n    this.authManager = AuthManagers.loadAuthManager(name, props);\n    this.closeables.addCloseable(this.authManager);\n\n    ConfigResponse config;\n    try (RESTClient initClient = clientBuilder.apply(props);\n        AuthSession initSession = authManager.initSession(initClient, props)) {\n      config = fetchConfig(initClient.withAuthSession(initSession), initSession, props);\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to close HTTP client\", e);\n    }\n\n    // build the final configuration and set up the catalog's auth\n    Map<String, String> mergedProps = config.merge(props);\n\n    // Enable Idempotency-Key header for mutation endpoints if the server advertises support\n    if (config.idempotencyKeyLifetime() != null) {\n      this.mutationHeaders = RESTUtil::idempotencyHeaders;\n    }\n\n    if (config.endpoints().isEmpty()) {\n      this.endpoints =\n          PropertyUtil.propertyAsBoolean(\n                  mergedProps,\n                  RESTCatalogProperties.VIEW_ENDPOINTS_SUPPORTED,\n                  RESTCatalogProperties.VIEW_ENDPOINTS_SUPPORTED_DEFAULT)\n              ? ImmutableSet.<Endpoint>builder()\n                  .addAll(DEFAULT_ENDPOINTS)","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java#L194-L230","documentation":"Thrown during RESTSessionCatalog.initialize when closing the temporary initialization RESTClient (or its init AuthSession) fails with an IOException. The config fetch itself succeeded, but the try-with-resources close of the bootstrap HTTP client failed, so initialization aborts with an UncheckedIOException.","triggerScenarios":"RESTCatalog.initialize() / file IO catalog initialization where the try-with-resources block closing the initClient or initSession throws IOException — typically underlying connection teardown failures during close.","commonSituations":"Transient network issues while closing the bootstrap connection used to fetch /v1/config; proxies or load balancers that reset idle connections; flaky TLS termination during the init session close.","solutions":["Check network/proxy stability between client and REST server; retry catalog initialization.","Inspect the wrapped IOException cause to see whether the server or an intermediary dropped the connection during close.","Upgrade Iceberg — client close robustness improvements land regularly in the rest module.","Verify server-side logs for errors on the /v1/config request lifecycle."],"exampleFix":"// before: exception only says 'Failed to close HTTP client'\nRESTCatalog catalog = new RESTCatalog();\ncatalog.initialize(\"prod\", props); // retry on UncheckedIOException\n// after: inspect cause and retry\ntry { catalog.initialize(\"prod\", props); }\ncatch (UncheckedIOException e) { LOG.warn(\"init close failed\", e.getCause()); /* retry with backoff */ }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { catalog.initialize(\"name\", props); } catch (UncheckedIOException e) { LOG.warn(\"init client close failed\", e.getCause()); /* retry with backoff */ }","preventionTips":["Ensure stable network/proxy connectivity to the REST catalog server","Log and inspect the wrapped IOException cause before assuming a config problem","Add bounded retry with backoff around catalog initialization","Keep Iceberg updated for rest-module close-handling fixes"],"tags":["rest","io","http-client","initialization"],"backgroundTag":"http-request-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"}