Skip to content

Commit 293957b

Browse files
committed
fixes access point name logic
1 parent 2f49eec commit 293957b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/ITestCustomSigner.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,13 @@ private String parseBucketFromHost(String host) {
228228
if (service.contains("s3-accesspoint") || service.contains("s3-outposts")
229229
|| service.contains("s3-object-lambda")) {
230230
// If AccessPoint then bucketName is of format `accessPoint-accountId`;
231-
String[] accessPointBits = hostBits[0].split("-");
232-
int lastElem = accessPointBits.length - 1;
233-
String accountId = accessPointBits[lastElem];
234-
String accessPointName = String.join("", Arrays.copyOf(accessPointBits, lastElem));
231+
String[] accessPointBits = bucketName.split("-");
232+
String accountId = accessPointBits[accessPointBits.length - 1];
233+
// Extract the access point name from bucket name. eg: if bucket name is
234+
// test-custom-signer-<accountId>, get the access point name test-custom-signer by removing
235+
// -<accountId> from the bucket name.
236+
String accessPointName =
237+
bucketName.substring(0, bucketName.length() - (accountId.length() + 1));
235238
Arn arn = Arn.builder()
236239
.withAccountId(accountId)
237240
.withPartition("aws")

0 commit comments

Comments
 (0)