Remove ServiceMetadata usage from DefaultS3Presigner, S3Utilities,and DefaultPollyPresigner#7110
Open
S-Saranya1 wants to merge 5 commits into
Conversation
…d DefaultPollyPresigner
…tadata-usage' into somepal/presigners-remove-servicemetadata
zoewangg
reviewed
Jul 14, 2026
| + testEndpoint + ". This is usually caused by an invalid region " | ||
| + "configuration."); | ||
| } | ||
| endpointProvider = ClientEndpointProvider.create(URI.create("https://localhost"), false); |
Contributor
There was a problem hiding this comment.
Hmm, why are we using localhost here?
NVM, it's used as a placeholder and will be replaced anyway. Can we follow the same pattern in EC2 and add some comments https://github.com/aws/aws-sdk-java-v2/blob/master/services/ec2/src/main/java/software/amazon/awssdk/services/ec2/transform/internal/GeneratePreSignUrlInterceptor.java#L67
| .resolveFromOverrides(); | ||
|
|
||
| ClientEndpointProvider endpointProvider; | ||
| if (overrideEndpoint.isPresent()) { |
Contributor
There was a problem hiding this comment.
Any reason we are not using S3EndpointProvider here?
zoewangg
reviewed
Jul 14, 2026
| .resolveFromOverrides(); | ||
|
|
||
| return overrideEndpoint.orElseGet(() -> CompletableFutureUtils.joinLikeSync( | ||
| PollyEndpointProvider.defaultProvider() |
Contributor
There was a problem hiding this comment.
Any reason we are not using localhost like we do in other presigners?
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.
Motivation and Context
Remove ServiceMetadata dependency from DefaultS3Presigner, S3Utilities, and DefaultPollyPresigner. These three classes call AwsClientEndpointProvider with serviceEndpointPrefix/defaultProtocol/region, which triggers the expensive clientEndpointFromServiceMetadata() code path — loading GeneratedServiceMetadataProvider and incurring 350-500ms static initialization overhead. This is part of the ServiceMetadata removal work, feature branch -
feature/master/remove-service-metadata-usageModifications
DefaultS3Presigner: Use resolveFromOverrides() to check for endpoint overrides/environment. If none found, use https://localhost placeholder (marked as not overridden) — S3ResolveEndpointInterceptor replaces it with the real endpoint during presigning. Added region validation at build time for fail-fast on invalid regions.
S3Utilities: Same approach — resolveFromOverrides() with localhost fallback. The endpoint is replaced by S3EndpointProvider during the getUrl() flow.
DefaultPollyPresigner: Use resolveFromOverrides() to check for overrides/environment. If none found, call PollyEndpointProvider (Endpoints 2.0) directly to get an accurate endpoint. Unlike S3, the Polly presigner has no downstream endpoint resolution — the endpoint becomes the final presigned URL host.
InvalidRegionTest: Updated assertions to match new error messages. S3Utilities errors now come from S3EndpointProvider ("Invalid region: region was not a valid DNS name.") and S3Presigner errors come from build-time validation ("Configured region .. resulted in an invalid URI"). the exception type is same, but the error message slightly varies( the exception type and fail-fast behavior are preserved).
Testing
S3PresignerTestandS3UtilitiesTestsuites validate full endpoint URLs (virtual-hosted, path-style, accelerate, dualstack, overrides) — any localhost leak would immediately fail these tests.InvalidRegionTestassertions to match new error messages.presign_noEndpointOverride_usesDefaultEndpointtest inDefaultPollyPresignerTestto verify that the Endpoints 2.0 fallback produces the correct host (polly.us-east-1.amazonaws.com).Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License