Skip to content

Commit 6f662bf

Browse files
committed
HADOOP-19740. flip the if() clause in client factory
1 parent 2b52e41 commit 6f662bf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/DefaultS3ClientFactory.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import static org.apache.hadoop.fs.s3a.auth.SignerFactory.createHttpSigner;
6969
import static org.apache.hadoop.fs.s3a.impl.AWSHeaders.REQUESTER_PAYS_HEADER;
7070
import static org.apache.hadoop.fs.s3a.impl.InternalConstants.AUTH_SCHEME_AWS_SIGV_4;
71+
import static org.apache.hadoop.fs.s3a.impl.RegionResolution.RegionResolutionMechanism.Ec2Metadata;
7172
import static org.apache.hadoop.fs.s3a.impl.RegionResolution.RegionResolutionMechanism.Sdk;
7273
import static org.apache.hadoop.fs.s3a.impl.RegionResolution.calculateRegion;
7374

@@ -313,7 +314,15 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> Regio
313314
// which tests expect.
314315
builder.fipsEnabled(resolution.isUseFips());
315316

316-
if (Sdk != resolution.getMechanism()) {
317+
final RegionResolution.RegionResolutionMechanism mechanism = resolution.getMechanism();
318+
if (Sdk == mechanism) {
319+
// handing off all resolution to SDK.
320+
// region configuration was set to empty string.
321+
// allow this if people really want it; it is OK to rely on this
322+
// when deployed in EC2.
323+
DEFAULT_REGION_CHAIN.info(SDK_REGION_CHAIN_IN_USE);
324+
LOG.debug(SDK_REGION_CHAIN_IN_USE);
325+
} else {
317326
final Region region = resolution.getRegion();
318327
builder.region(requireNonNull(region));
319328
// s3 cross region access
@@ -327,13 +336,6 @@ private <BuilderT extends S3BaseClientBuilder<BuilderT, ClientT>, ClientT> Regio
327336
LOG.debug("Setting endpoint to {}", endpointUri);
328337
}
329338
}
330-
} else {
331-
// handing off all resolution to SDK.
332-
// region configuration was set to empty string.
333-
// allow this if people really want it; it is OK to rely on this
334-
// when deployed in EC2.
335-
DEFAULT_REGION_CHAIN.info(SDK_REGION_CHAIN_IN_USE);
336-
LOG.debug(SDK_REGION_CHAIN_IN_USE);
337339
}
338340
return resolution;
339341
}

0 commit comments

Comments
 (0)