Skip to content

AWS: Isolate S3 remote signer auth and HTTP state per catalog#16524

Open
wombatu-kun wants to merge 1 commit into
apache:mainfrom
wombatu-kun:issue/16460-signer-state-isolation
Open

AWS: Isolate S3 remote signer auth and HTTP state per catalog#16524
wombatu-kun wants to merge 1 commit into
apache:mainfrom
wombatu-kun:issue/16460-signer-state-isolation

Conversation

@wombatu-kun
Copy link
Copy Markdown
Contributor

Closes #16460.

Summary

S3V4RestSignerClient kept its AuthManager and RESTClient in process-wide static volatile fields, lazily initialized from the first catalog's properties. In a JVM that talks to more than one catalog the first catalog to initialize these fields won: any later catalog with a different auth type, different OAuth credentials, or different custom HTTP headers silently reused the first catalog's auth manager and HTTP client. That is the cross-catalog leakage reported in #16460. PR #14178 previously removed the base-URI pinning from the shared client but deliberately left the static fields in place; this change finishes the cleanup by making the auth/HTTP state per signer instance.

What changed

The authManager and httpClient fields are now per-instance (double-checked locking on the instance rather than the class), so each signer owns its own auth manager and HTTP client. One signer is created per S3Client build — bounded by the number of catalogs and storage prefixes, never per request — so this is cheap, and the previous "first catalog wins" sharing bought nothing.

The HTTP client is now built through a settable httpClientSupplier() default, which keeps per-catalog headers and timeouts isolated and provides a seam for injecting a mock client in tests. The previously empty close() now releases the per-instance auth manager and HTTP client via IoUtils.closeQuietlyV2.

The static SIGNED_COMPONENT_CACHE is intentionally left shared: it is keyed by request identity (method, region, URI) — a property of the S3 request being signed, not of any catalog or credential — so sharing it across catalogs is safe.

Tests

Added regression tests in TestS3V4RestSignerClient showing two signer instances with different configuration no longer share state: distinct HTTP clients per instance, distinct auth managers of distinct types when auth differs, and that close() releases the HTTP client. Reworked the existing unit and integration tests to inject the HTTP client per instance and to release the signer through close() instead of nulling the removed static fields.

@github-actions github-actions Bot added the AWS label May 22, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wombatu-kun wombatu-kun force-pushed the issue/16460-signer-state-isolation branch from 9a1a09d to 7d596a1 Compare May 22, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3 remote signer clients share auth and HTTP state across catalogs

1 participant