AWS: Isolate S3 remote signer auth and HTTP state per catalog#16524
Open
wombatu-kun wants to merge 1 commit into
Open
AWS: Isolate S3 remote signer auth and HTTP state per catalog#16524wombatu-kun wants to merge 1 commit into
wombatu-kun wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9a1a09d to
7d596a1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16460.
Summary
S3V4RestSignerClientkept itsAuthManagerandRESTClientin process-widestatic volatilefields, 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
authManagerandhttpClientfields 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 perS3Clientbuild — 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 emptyclose()now releases the per-instance auth manager and HTTP client viaIoUtils.closeQuietlyV2.The static
SIGNED_COMPONENT_CACHEis 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
TestS3V4RestSignerClientshowing 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 thatclose()releases the HTTP client. Reworked the existing unit and integration tests to inject the HTTP client per instance and to release the signer throughclose()instead of nulling the removed static fields.