From d97750b52c033b36677f4fe3b60c21510a0ad9f6 Mon Sep 17 00:00:00 2001 From: David Pilato Date: Thu, 26 Jan 2017 17:20:27 +0100 Subject: [PATCH] Fix checkstyle and a test --- .../discovery/ec2/AwsEc2UnicastHostsProvider.java | 6 ++++-- .../org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java index 5e97e92fa52..d2a8f6e5f3f 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java @@ -174,6 +174,8 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni logger.debug("using [{}] as the instance address", address); } } + } else { + throw new IllegalArgumentException(hostType + " is unknown for discovery.ec2.host_type"); } if (address != null) { try { @@ -181,8 +183,8 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni TransportAddress[] addresses = transportService.addressesFromString(address, 1); for (int i = 0; i < addresses.length; i++) { logger.trace("adding {}, address {}, transport_address {}", instance.getInstanceId(), address, addresses[i]); - discoNodes.add(new DiscoveryNode(instance.getInstanceId(), "#cloud-" + instance.getInstanceId() + "-" + i, addresses[i], - emptyMap(), emptySet(), Version.CURRENT.minimumCompatibilityVersion())); + discoNodes.add(new DiscoveryNode(instance.getInstanceId(), "#cloud-" + instance.getInstanceId() + "-" + i, + addresses[i], emptyMap(), emptySet(), Version.CURRENT.minimumCompatibilityVersion())); } } catch (Exception e) { final String finalAddress = address; diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java index 59193556309..34e5345016d 100644 --- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java +++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java @@ -201,7 +201,7 @@ public class Ec2DiscoveryTests extends ESTestCase { buildDynamicNodes(nodeSettings, 1); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), containsString("No enum constant")); + assertThat(e.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type")); } }