Skip to content

Commit 4e842a7

Browse files
ahmarsuhailmukund-thakur
authored andcommitted
HADOOP-18368. Fixes ITestCustomSigner for access point names with '-' (#4634)
Contributed By: Ahmar Suhail <[email protected]>
1 parent 7aebace commit 4e842a7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.io.IOException;
2222
import java.security.PrivilegedExceptionAction;
23-
import java.util.Arrays;
2423
import java.util.HashMap;
2524
import java.util.Map;
2625
import java.util.Objects;
@@ -228,10 +227,13 @@ private String parseBucketFromHost(String host) {
228227
if (service.contains("s3-accesspoint") || service.contains("s3-outposts")
229228
|| service.contains("s3-object-lambda")) {
230229
// 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));
230+
String[] accessPointBits = bucketName.split("-");
231+
String accountId = accessPointBits[accessPointBits.length - 1];
232+
// Extract the access point name from bucket name. eg: if bucket name is
233+
// test-custom-signer-<accountId>, get the access point name test-custom-signer by removing
234+
// -<accountId> from the bucket name.
235+
String accessPointName =
236+
bucketName.substring(0, bucketName.length() - (accountId.length() + 1));
235237
Arn arn = Arn.builder()
236238
.withAccountId(accountId)
237239
.withPartition("aws")

0 commit comments

Comments
 (0)