From 899e84c01ece898bbae6066ce24c0cba3102fc8a Mon Sep 17 00:00:00 2001 From: David Pilato Date: Wed, 29 Apr 2015 11:22:28 +0200 Subject: [PATCH] Remove `ElasticsearchIllegalArgumentException` and `ElasticsearchIllegalStateException` in favor of the JDK one Related to https://github.com/elastic/elasticsearch/issues/10794 Closes #204. --- .../java/org/elasticsearch/cloud/aws/AwsEc2Service.java | 9 ++++----- src/main/java/org/elasticsearch/cloud/aws/AwsSigner.java | 9 ++++----- .../elasticsearch/cloud/aws/InternalAwsS3Service.java | 9 ++++----- .../java/org/elasticsearch/cloud/aws/AWSSignersTest.java | 3 +-- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java index 5e432b3fbb6..70f8e88def8 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java @@ -26,7 +26,6 @@ import com.amazonaws.internal.StaticCredentialsProvider; import com.amazonaws.services.ec2.AmazonEC2; import com.amazonaws.services.ec2.AmazonEC2Client; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.ElasticsearchIllegalArgumentException; import org.elasticsearch.cloud.aws.network.Ec2NameResolver; import org.elasticsearch.cloud.aws.node.Ec2CustomNodeAttributes; import org.elasticsearch.cluster.node.DiscoveryNodeService; @@ -70,7 +69,7 @@ public class AwsEc2Service extends AbstractLifecycleComponent { } else if ("https".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTPS); } else { - throw new ElasticsearchIllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]"); + throw new IllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]"); } String account = settings.get("cloud.aws.access_key", settings.get("cloud.account")); String key = settings.get("cloud.aws.secret_key", settings.get("cloud.key")); @@ -84,7 +83,7 @@ public class AwsEc2Service extends AbstractLifecycleComponent { try { proxyPort = Integer.parseInt(portString, 10); } catch (NumberFormatException ex) { - throw new ElasticsearchIllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex); + throw new IllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex); } clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort); } @@ -95,7 +94,7 @@ public class AwsEc2Service extends AbstractLifecycleComponent { logger.debug("using AWS API signer [{}]", awsSigner); try { AwsSigner.configureSigner(awsSigner, clientConfiguration); - } catch (ElasticsearchIllegalArgumentException e) { + } catch (IllegalArgumentException e) { logger.warn("wrong signer set for [cloud.aws.ec2.signer] or [cloud.aws.signer]: [{}]", awsSigner); } } @@ -144,7 +143,7 @@ public class AwsEc2Service extends AbstractLifecycleComponent { } else if (region.equals("cn-north") || region.equals("cn-north-1")) { endpoint = "ec2.cn-north-1.amazonaws.com.cn"; } else { - throw new ElasticsearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]"); + throw new IllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]"); } if (endpoint != null) { logger.debug("using ec2 region [{}], with endpoint [{}]", region, endpoint); diff --git a/src/main/java/org/elasticsearch/cloud/aws/AwsSigner.java b/src/main/java/org/elasticsearch/cloud/aws/AwsSigner.java index c05e81eeac2..476bb7428e8 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/AwsSigner.java +++ b/src/main/java/org/elasticsearch/cloud/aws/AwsSigner.java @@ -21,7 +21,6 @@ package org.elasticsearch.cloud.aws; import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.SignerFactory; -import org.elasticsearch.ElasticsearchIllegalArgumentException; public class AwsSigner { @@ -33,13 +32,13 @@ public class AwsSigner { * Add a AWS API Signer. * @param signer Signer to use * @param configuration AWS Client configuration - * @throws ElasticsearchIllegalArgumentException if signer does not exist + * @throws IllegalArgumentException if signer does not exist */ public static void configureSigner(String signer, ClientConfiguration configuration) - throws ElasticsearchIllegalArgumentException { + throws IllegalArgumentException { if (signer == null) { - throw new ElasticsearchIllegalArgumentException("[null] signer set"); + throw new IllegalArgumentException("[null] signer set"); } try { @@ -48,7 +47,7 @@ public class AwsSigner { SignerFactory.getSignerByTypeAndService(signer, null); configuration.setSignerOverride(signer); } catch (IllegalArgumentException e) { - throw new ElasticsearchIllegalArgumentException("wrong signer set [" + signer + "]"); + throw new IllegalArgumentException("wrong signer set [" + signer + "]"); } } } diff --git a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index 6f1c239313c..b574739f3e3 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -27,7 +27,6 @@ import com.amazonaws.internal.StaticCredentialsProvider; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.ElasticsearchIllegalArgumentException; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; @@ -100,7 +99,7 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent