From d9d76a7bbd92c9ebe6e5a976e358faf52a683769 Mon Sep 17 00:00:00 2001 From: Anupam Yadav Date: Sat, 18 Apr 2026 22:03:58 +0000 Subject: [PATCH] AWS: Apply service configurations to S3AsyncClient (#14575) Apply S3FileIOProperties.applyServiceConfigurations() to the S3AsyncClient builder, matching the existing sync S3Client configuration. Without this, settings like s3.path-style-access and s3.dualstack-enabled silently do not apply to async operations. --- .../iceberg/aws/AwsClientFactories.java | 1 + .../iceberg/aws/s3/S3FileIOProperties.java | 5 ++- .../aws/s3/TestS3FileIOProperties.java | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java b/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java index e6eb8d28d01a..e27fbe28b69d 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java +++ b/aws/src/main/java/org/apache/iceberg/aws/AwsClientFactories.java @@ -138,6 +138,7 @@ public S3AsyncClient s3Async() { .applyMutation( b -> s3FileIOProperties.applyCredentialConfigurations(awsClientProperties, b)) .applyMutation(s3FileIOProperties::applyEndpointConfigurations) + .applyMutation(s3FileIOProperties::applyServiceConfigurations) .build(); } diff --git a/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIOProperties.java b/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIOProperties.java index 922010d61d27..63c965ca46c4 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIOProperties.java +++ b/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIOProperties.java @@ -1003,10 +1003,11 @@ private AwsCredentialsProvider getCredentialsProvider(AwsClientProperties awsCli *

Sample usage: * *

-   *     S3Client.builder().applyMutation(s3FileIOProperties::applyS3ServiceConfigurations)
+   *     S3Client.builder().applyMutation(s3FileIOProperties::applyServiceConfigurations)
+   *     S3AsyncClient.builder().applyMutation(s3FileIOProperties::applyServiceConfigurations)
    * 
*/ - public void applyServiceConfigurations(T builder) { + public > void applyServiceConfigurations(T builder) { builder .dualstackEnabled(isDualStackEnabled) .crossRegionAccessEnabled(isCrossRegionAccessEnabled) diff --git a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java index 953f73d45d4a..071eb17fca0f 100644 --- a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java +++ b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java @@ -497,6 +497,44 @@ public void testApplyS3ServiceConfigurations() { .isFalse(); } + @Test + public void testApplyS3AsyncServiceConfigurations() { + Map properties = Maps.newHashMap(); + properties.put(S3FileIOProperties.DUALSTACK_ENABLED, "true"); + properties.put(S3FileIOProperties.CROSS_REGION_ACCESS_ENABLED, "true"); + properties.put(S3FileIOProperties.PATH_STYLE_ACCESS, "true"); + properties.put(S3FileIOProperties.USE_ARN_REGION_ENABLED, "true"); + properties.put(S3FileIOProperties.ACCELERATION_ENABLED, "false"); + S3FileIOProperties s3FileIOProperties = new S3FileIOProperties(properties); + S3AsyncClientBuilder mockBuilder = Mockito.mock(S3AsyncClientBuilder.class); + + ArgumentCaptor s3ConfigurationCaptor = + ArgumentCaptor.forClass(S3Configuration.class); + + Mockito.doReturn(mockBuilder).when(mockBuilder).dualstackEnabled(Mockito.anyBoolean()); + Mockito.doReturn(mockBuilder) + .when(mockBuilder) + .crossRegionAccessEnabled(Mockito.anyBoolean()); + Mockito.doReturn(mockBuilder) + .when(mockBuilder) + .serviceConfiguration(Mockito.any(S3Configuration.class)); + + s3FileIOProperties.applyServiceConfigurations(mockBuilder); + + Mockito.verify(mockBuilder).serviceConfiguration(s3ConfigurationCaptor.capture()); + + S3Configuration s3Configuration = s3ConfigurationCaptor.getValue(); + assertThat(s3Configuration.pathStyleAccessEnabled()) + .as("s3 async path style access enabled parameter should be set to true") + .isTrue(); + assertThat(s3Configuration.useArnRegionEnabled()) + .as("s3 async use arn region enabled parameter should be set to true") + .isTrue(); + assertThat(s3Configuration.accelerateModeEnabled()) + .as("s3 async acceleration mode enabled parameter should be set to false") + .isFalse(); + } + @Test public void testApplySignerConfiguration() { Map properties =