NIFI-13251 Replaced deprecated AWS method Region.fromName()

This closes #8848

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
dan-s1 2024-05-17 20:40:55 +00:00 committed by exceptionfactory
parent 24b13d7a3e
commit 2e7e3733f3
No known key found for this signature in database
3 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.http.conn.ssl.SdkTLSSocketFactory; import com.amazonaws.http.conn.ssl.SdkTLSSocketFactory;
import com.amazonaws.regions.Region; import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions; import com.amazonaws.regions.RegionUtils;
import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import org.apache.http.conn.ssl.DefaultHostnameVerifier; import org.apache.http.conn.ssl.DefaultHostnameVerifier;
@ -306,7 +306,7 @@ public abstract class AbstractAWSCredentialsProviderProcessor<ClientType extends
if (getSupportedPropertyDescriptors().contains(REGION)) { if (getSupportedPropertyDescriptors().contains(REGION)) {
final String regionValue = context.getProperty(REGION).getValue(); final String regionValue = context.getProperty(REGION).getValue();
if (regionValue != null) { if (regionValue != null) {
return Region.getRegion(Regions.fromName(regionValue)); return RegionUtils.getRegion(regionValue);
} }
} }

View File

@ -17,6 +17,7 @@
package org.apache.nifi.processors.aws.util; package org.apache.nifi.processors.aws.util;
import com.amazonaws.regions.Region; import com.amazonaws.regions.Region;
import com.amazonaws.regions.RegionUtils;
import com.amazonaws.regions.Regions; import com.amazonaws.regions.Regions;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.nifi.components.AllowableValue; import org.apache.nifi.components.AllowableValue;
@ -84,7 +85,7 @@ public final class RegionUtilV1 {
} }
try { try {
return Region.getRegion(Regions.fromName(regionValue)); return RegionUtils.getRegion(regionValue);
} catch (Exception e) { } catch (Exception e) {
throw new ProcessException(String.format("The [%s] attribute contains an invalid region value [%s]", S3_REGION_ATTRIBUTE, regionValue), e); throw new ProcessException(String.format("The [%s] attribute contains an invalid region value [%s]", S3_REGION_ATTRIBUTE, regionValue), e);
} }

View File

@ -16,8 +16,7 @@
*/ */
package org.apache.nifi.processors.aws.s3.encryption; package org.apache.nifi.processors.aws.s3.encryption;
import com.amazonaws.regions.Region; import com.amazonaws.regions.RegionUtils;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Builder; import com.amazonaws.services.s3.AmazonS3Builder;
import com.amazonaws.services.s3.AmazonS3EncryptionClientV2; import com.amazonaws.services.s3.AmazonS3EncryptionClientV2;
@ -50,7 +49,7 @@ public class ClientSideKMSEncryptionStrategy implements S3EncryptionStrategy {
final CryptoConfigurationV2 cryptoConfig = new CryptoConfigurationV2(); final CryptoConfigurationV2 cryptoConfig = new CryptoConfigurationV2();
if (StringUtils.isNotBlank(kmsRegion)) { if (StringUtils.isNotBlank(kmsRegion)) {
cryptoConfig.setAwsKmsRegion(Region.getRegion(Regions.fromName(kmsRegion))); cryptoConfig.setAwsKmsRegion(RegionUtils.getRegion(kmsRegion));
} }
final AmazonS3EncryptionClientV2Builder builder = AmazonS3EncryptionClientV2.encryptionBuilder() final AmazonS3EncryptionClientV2Builder builder = AmazonS3EncryptionClientV2.encryptionBuilder()