From a7cc13ee3e4dba5d28417afe8fda53887025b256 Mon Sep 17 00:00:00 2001 From: John Viegas Date: Fri, 27 Dec 2024 11:38:23 -0800 Subject: [PATCH] Handled comments --- .../Sigv4aSigningRegionSetProvider.java | 14 ++++++-------- .../{ => auth}/Sigv4aSigningRegionSetTest.java | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) rename test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/{ => auth}/Sigv4aSigningRegionSetTest.java (94%) diff --git a/core/aws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/Sigv4aSigningRegionSetProvider.java b/core/aws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/Sigv4aSigningRegionSetProvider.java index ce0da33a788..35d092be271 100644 --- a/core/aws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/Sigv4aSigningRegionSetProvider.java +++ b/core/aws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/Sigv4aSigningRegionSetProvider.java @@ -17,6 +17,7 @@ import java.util.Arrays; +import java.util.Collections; import java.util.Optional; import java.util.Set; import java.util.function.Supplier; @@ -31,7 +32,6 @@ import software.amazon.awssdk.utils.StringUtils; import software.amazon.awssdk.utils.Validate; - @SdkProtectedApi public final class Sigv4aSigningRegionSetProvider { private final Supplier profileFile; @@ -59,28 +59,26 @@ public Set resolveRegionSet() { private Set regionSet() { Optional setting = SdkSystemSetting.AWS_SIGV4A_SIGNING_REGION_SET.getStringValue(); if (setting.isPresent()) { - return parseRegionSet(setting.get()).orElse(null); + return parseRegionSet(setting.get()); } - ProfileFile file = this.profileFile.get(); Optional profile = file.profile(profileName()); return profile .flatMap(p -> p.property(ProfileProperty.SIGV4A_SIGNING_REGION_SET)) - .flatMap(this::parseRegionSet) + .map(this::parseRegionSet) .orElse(null); } - private Optional> parseRegionSet(String value) { + private Set parseRegionSet(String value) { if (StringUtils.isBlank(value)) { - return Optional.empty(); + return null; } - Set regions = Arrays.stream(value.split(",")) .map(String::trim) .filter(s -> !s.isEmpty()) .collect(Collectors.toSet()); - return regions.isEmpty() ? Optional.empty() : Optional.of(regions); + return regions.isEmpty() ? null : Collections.unmodifiableSet(regions); } private String profileName() { diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/Sigv4aSigningRegionSetTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/auth/Sigv4aSigningRegionSetTest.java similarity index 94% rename from test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/Sigv4aSigningRegionSetTest.java rename to test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/auth/Sigv4aSigningRegionSetTest.java index beadf047f99..66957d53b6d 100644 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/Sigv4aSigningRegionSetTest.java +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/auth/Sigv4aSigningRegionSetTest.java @@ -1,4 +1,19 @@ -package software.amazon.awssdk.services; +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package software.amazon.awssdk.services.auth; import static org.assertj.core.api.Assertions.assertThat;