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) { if (regionOrEndpointSet) { <START> log.warn("Ignoring the S3 endpoint configuration as region has already been set by pinning the S3 client to the current region."); <END> } else { clientBuilder = clientBuilder.withEndpointConfiguration(new EndpointConfiguration(endpoint, null)); regionOrEndpointSet = true; } } if (isPathStyleAccess) { clientBuilder = clientBuilder.enablePathStyleAccess(); } if (!regionOrEndpointSet) { clientBuilder = clientBuilder.withRegion(Regions.DEFAULT_REGION); } return clientBuilder.build(); }</code><technical_language>considering this invalid configuration throwing instead</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); } return clientBuilder.build(); }