apache/iceberg · warning · UncheckedIOException

Failed to close the OAuth2RefreshCredentialsHandler

Error message

Failed to close the OAuth2RefreshCredentialsHandler

What it means

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.

Solutions

  1. Inspect the chained IOException cause; close-failures are often benign resource leaks
  2. Ensure close() is called once (use try-with-resources)
  3. Upgrade/verify REST client and auth manager versions for known close bugs
  4. Log and continue if the failure is only cleanup-related

Example fix

// before
handler.close();
// after
try (OAuth2RefreshCredentialsHandler handler = ...) {
  // use handler
} // close failures are reported, not masking real errors (suppressCloseFailure=true)
Defensive patterns

Strategy: try-catch

Try / catch

try (OAuth2RefreshCredentialsHandler h = ...) { /* use */ } catch (UncheckedIOException e) { LOG.warn("Cleanup failure", e.getCause()); }

Prevention

When it happens

Trigger: Calling close() on OAuth2RefreshCredentialsHandler when the underlying REST client or AuthManager throws IOException during shutdown.

Common situations: Client already closed; underlying HTTP connection in a broken state; failures during token revocation on close.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/d0a8674fb9c3bba7. Report an issue: GitHub.

Appendix: source

Thrown at gcp/src/main/java/org/apache/iceberg/gcp/gcs/OAuth2RefreshCredentialsHandler.java:142

          client = httpClient.withAuthSession(authSession);
        }
      }
    }

    return client;
  }

  @Override
  public void close() {
    CloseableGroup closeableGroup = new CloseableGroup();
    closeableGroup.addCloseable(authSession);
    closeableGroup.addCloseable(authManager);
    closeableGroup.addCloseable(client);
    closeableGroup.setSuppressCloseFailure(true);
    try {
      closeableGroup.close();
    } catch (IOException e) {
      throw new UncheckedIOException("Failed to close the OAuth2RefreshCredentialsHandler", e);
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)