Source:
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); } if (globalBucketAccessEnabled) { clientBuilder.setForceGlobalBucketAccessEnabled(true); } return clientBuilder.build(); }

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(); }