cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/3] cassandra git commit: Fix NPE in nodetool getendpoints with bad ks/cf
Date Fri, 20 Mar 2015 16:44:55 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 237d0bc62 -> f1db1afe9


Fix NPE in nodetool getendpoints with bad ks/cf

Patch by Stefania Alborghetti; reviewed by Tyler Hobbs for
CASSANDRA-8950


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/37eb2a0e
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/37eb2a0e
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/37eb2a0e

Branch: refs/heads/trunk
Commit: 37eb2a0e29c22a1b2f033e8191b5808a6f7b0d3f
Parents: 5fd4a01
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Fri Mar 20 11:37:23 2015 -0500
Committer: Tyler Hobbs <tylerhobbs@apache.org>
Committed: Fri Mar 20 11:37:23 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                            |  2 ++
 .../org/apache/cassandra/service/StorageService.java   |  9 ++++++++-
 src/java/org/apache/cassandra/tools/NodeCmd.java       | 13 +++++++++----
 src/java/org/apache/cassandra/tools/NodeProbe.java     |  5 +++++
 4 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/37eb2a0e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f10a89a..25fbd74 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37eb2a0e/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 8085d7b..622380e 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -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)));
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37eb2a0e/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index df53347..bc5410f 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -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
+        {
+            List<InetAddress> endpoints = probe.getEndpoints(keySpace, cf, key);
+            for (InetAddress anEndpoint : endpoints)
+               output.println(anEndpoint.getHostAddress());
+        }
+        catch (IllegalArgumentException ex)
         {
-           output.println(anEndpoint.getHostAddress());
+            output.println(ex.getMessage());
+            probe.failed();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37eb2a0e/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 6b28f18..d66d12d 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -907,6 +907,11 @@ public class NodeProbe
         ssProxy.resetLocalSchema();
     }
 
+    public void failed()
+    {
+        failed = true;
+    }
+
     public boolean isFailed()
     {
         return failed;


Mime
View raw message