Fix NPE in nodetool getendpoints with bad ks/cf

Patch by Stefania Alborghetti; reviewed by Tyler Hobbs for
CASSANDRA-8950
This commit is contained in:
Stefania Alborghetti 2015-03-20 11:37:23 -05:00 committed by Tyler Hobbs
parent 5fd4a01165
commit 37eb2a0e29
4 changed files with 24 additions and 5 deletions

View File

@ -1,4 +1,6 @@
2.0.14:
* Fix NullPointerException when nodetool getendpoints is run
against invalid keyspaces or tables (CASSANDRA-8950)
* Allow specifying the tmp dir (CASSANDRA-7712)
* Improve compaction estimated tasks estimation (CASSANDRA-8904)
* Fix duplicate up/down messages sent to native clients (CASSANDRA-7816)

View File

@ -2778,7 +2778,14 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
*/
public List<InetAddress> getNaturalEndpoints(String keyspaceName, String cf, String key)
{
CFMetaData cfMetaData = Schema.instance.getKSMetaData(keyspaceName).cfMetaData().get(cf);
KSMetaData ksMetaData = Schema.instance.getKSMetaData(keyspaceName);
if (ksMetaData == null)
throw new IllegalArgumentException("Unknown keyspace '" + keyspaceName + "'");
CFMetaData cfMetaData = ksMetaData.cfMetaData().get(cf);
if (cfMetaData == null)
throw new IllegalArgumentException("Unknown table '" + cf + "' in keyspace '" + keyspaceName + "'");
return getNaturalEndpoints(keyspaceName, getPartitioner().getToken(cfMetaData.getKeyValidator().fromString(key)));
}

View File

@ -1182,11 +1182,16 @@ public class NodeCmd
private void printEndPoints(String keySpace, String cf, String key, PrintStream output)
{
List<InetAddress> endpoints = this.probe.getEndpoints(keySpace, cf, key);
for (InetAddress anEndpoint : endpoints)
try
{
output.println(anEndpoint.getHostAddress());
List<InetAddress> endpoints = probe.getEndpoints(keySpace, cf, key);
for (InetAddress anEndpoint : endpoints)
output.println(anEndpoint.getHostAddress());
}
catch (IllegalArgumentException ex)
{
output.println(ex.getMessage());
probe.failed();
}
}

View File

@ -907,6 +907,11 @@ public class NodeProbe
ssProxy.resetLocalSchema();
}
public void failed()
{
failed = true;
}
public boolean isFailed()
{
return failed;