From 123d1aa8846a2099b04fd8e8ed7f2bd6db4f36b5 Mon Sep 17 00:00:00 2001 From: ahmarsuhail Date: Mon, 1 Aug 2022 21:19:42 +0100 Subject: [PATCH] HADOOP-18368. Fixes ITestCustomSigner for access point names with '-' (#4634) Contributed By: Ahmar Suhail --- .../apache/hadoop/fs/s3a/auth/ITestCustomSigner.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/ITestCustomSigner.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/ITestCustomSigner.java index cbba326d5ec..a829d470e7a 100644 --- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/ITestCustomSigner.java +++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/auth/ITestCustomSigner.java @@ -20,7 +20,6 @@ package org.apache.hadoop.fs.s3a.auth; import java.io.IOException; import java.security.PrivilegedExceptionAction; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -228,10 +227,13 @@ public class ITestCustomSigner extends AbstractS3ATestBase { if (service.contains("s3-accesspoint") || service.contains("s3-outposts") || service.contains("s3-object-lambda")) { // If AccessPoint then bucketName is of format `accessPoint-accountId`; - String[] accessPointBits = hostBits[0].split("-"); - int lastElem = accessPointBits.length - 1; - String accountId = accessPointBits[lastElem]; - String accessPointName = String.join("", Arrays.copyOf(accessPointBits, lastElem)); + String[] accessPointBits = bucketName.split("-"); + String accountId = accessPointBits[accessPointBits.length - 1]; + // Extract the access point name from bucket name. eg: if bucket name is + // test-custom-signer-, get the access point name test-custom-signer by removing + // - from the bucket name. + String accessPointName = + bucketName.substring(0, bucketName.length() - (accountId.length() + 1)); Arn arn = Arn.builder() .withAccountId(accountId) .withPartition("aws")