Throw correct exception type, reduce boilerplate in boolean statement

Original commit: elastic/x-pack-elasticsearch@1e33c4d8f2
This commit is contained in:
Lee Hinman 2016-06-30 09:34:08 -06:00
parent 92637d2eec
commit 238eed2075
2 changed files with 3 additions and 5 deletions

View File

@ -221,7 +221,7 @@ public class ESNativeRealmMigrateTool extends MultiCommand {
parser.skipChildren(); parser.skipChildren();
} }
} else { } else {
throw new Exception("failed to retrieve users, expecting an object but got: " + token); throw new ElasticsearchException("failed to retrieve users, expecting an object but got: " + token);
} }
} }
terminal.println("found existing users: " + existingUsers); terminal.println("found existing users: " + existingUsers);
@ -296,7 +296,7 @@ public class ESNativeRealmMigrateTool extends MultiCommand {
parser.skipChildren(); parser.skipChildren();
} }
} else { } else {
throw new Exception("failed to retrieve roles, expecting an object but got: " + token); throw new ElasticsearchException("failed to retrieve roles, expecting an object but got: " + token);
} }
} }
terminal.println("found existing roles: " + existingRoles); terminal.println("found existing roles: " + existingRoles);

View File

@ -373,9 +373,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase {
final List<NodeInfo> nodes = nodeInfos.getNodes(); final List<NodeInfo> nodes = nodeInfos.getNodes();
assertTrue("there is at least one node", nodes.size() > 0); assertTrue("there is at least one node", nodes.size() > 0);
NodeInfo ni = randomFrom(nodes); NodeInfo ni = randomFrom(nodes);
if (SecurityNettyHttpServerTransport.SSL_SETTING.get(ni.getSettings())) { useSSL = SecurityNettyHttpServerTransport.SSL_SETTING.get(ni.getSettings());
useSSL = true;
}
TransportAddress publishAddress = ni.getHttp().address().publishAddress(); TransportAddress publishAddress = ni.getHttp().address().publishAddress();
assertEquals(1, publishAddress.uniqueAddressTypeId()); assertEquals(1, publishAddress.uniqueAddressTypeId());
InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address(); InetSocketAddress address = ((InetSocketTransportAddress) publishAddress).address();