Source:
<code>private AmazonS3 createAmazonS3Client(URI uri, Configuration hadoopConfig, ClientConfiguration clientConfig) { AWSCredentialsProvider credentials = getAwsCredentialsProvider(uri, hadoopConfig); Optional<EncryptionMaterialsProvider> encryptionMaterialsProvider = createEncryptionMaterialsProvider(hadoopConfig); AmazonS3Builder<? extends AmazonS3Builder, ? extends AmazonS3> clientBuilder; String signerType = hadoopConfig.get(S3_SIGNER_TYPE); if (signerType != null) { clientConfig.withSignerOverride(signerType); } if (encryptionMaterialsProvider.isPresent()) { clientBuilder = AmazonS3EncryptionClient.encryptionBuilder() .withCredentials(credentials) .withEncryptionMaterials(encryptionMaterialsProvider.get()) .withClientConfiguration(clientConfig) .withMetricsCollector(METRIC_COLLECTOR); } else { clientBuilder = AmazonS3Client.builder() .withCredentials(credentials) .withClientConfiguration(clientConfig) .withMetricsCollector(METRIC_COLLECTOR); } boolean regionOrEndpointSet = false; if (pinS3ClientToCurrentRegion) { Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder = clientBuilder.withRegion(region.getName()); regionOrEndpointSet = true; } } String endpoint = hadoopConfig.get(S3_ENDPOINT); if (endpoint != null) { clientBuilder = clientBuilder.withEndpointConfiguration(new EndpointConfiguration(endpoint, null)); regionOrEndpointSet = true; } if (isPathStyleAccess) { clientBuilder = clientBuilder.enablePathStyleAccess(); <START> } <END> if (!regionOrEndpointSet) { clientBuilder = clientBuilder.withRegion(US_EAST_1); } if (globalBucketAccessEnabled) { clientBuilder.setForceGlobalBucketAccessEnabled(true); } return clientBuilder.build(); }</code><technical_language>drawbacks if this (as effectively migration client builder)? <LINK_0> lists drawback: > Enabling this mode drawbacks, potential increase latency in event location of bucket is physically location request invoked. AFAIU this "it work slow in cases fail quickly"</technical_language>

Target:
private AmazonS3 createAmazonS3Client(URI uri, Configuration hadoopConfig, ClientConfiguration clientConfig) { AWSCredentialsProvider credentials = getAwsCredentialsProvider(uri, hadoopConfig); Optional<EncryptionMaterialsProvider> encryptionMaterialsProvider = createEncryptionMaterialsProvider(hadoopConfig); AmazonS3Builder<? extends AmazonS3Builder, ? extends AmazonS3> clientBuilder; String signerType = hadoopConfig.get(S3_SIGNER_TYPE); if (signerType != null) { clientConfig.withSignerOverride(signerType); } if (encryptionMaterialsProvider.isPresent()) { clientBuilder = AmazonS3EncryptionClient.encryptionBuilder() .withCredentials(credentials) .withEncryptionMaterials(encryptionMaterialsProvider.get()) .withClientConfiguration(clientConfig) .withMetricsCollector(METRIC_COLLECTOR); } else { clientBuilder = AmazonS3Client.builder() .withCredentials(credentials) .withClientConfiguration(clientConfig) .withMetricsCollector(METRIC_COLLECTOR); } boolean regionOrEndpointSet = false; if (pinS3ClientToCurrentRegion) { Region region = Regions.getCurrentRegion(); if (region != null) { clientBuilder = clientBuilder.withRegion(region.getName()); regionOrEndpointSet = true; } } String endpoint = hadoopConfig.get(S3_ENDPOINT); if (endpoint != null) { clientBuilder = clientBuilder.withEndpointConfiguration(new EndpointConfiguration(endpoint, null)); regionOrEndpointSet = true; } if (isPathStyleAccess) { clientBuilder = clientBuilder.enablePathStyleAccess(); } if (!regionOrEndpointSet) { clientBuilder = clientBuilder.withRegion(US_EAST_1); clientBuilder.setForceGlobalBucketAccessEnabled(true); } return clientBuilder.build(); }