cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobr...@apache.org
Subject [03/10] cassandra git commit: Fix nodetool compactionstats NPE
Date Tue, 13 Dec 2016 12:37:36 GMT
Fix nodetool compactionstats NPE

patch by Jay Zhuang; reviewed by jasobrown for CASSANDRA-13021


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

Branch: refs/heads/cassandra-3.X
Commit: 5d8f6c64c40612462bbecaef8e21c0f7baf5b815
Parents: 36ce4e0
Author: Jay Zhuang <jay.zhuang@yahoo.com>
Authored: Thu Dec 8 14:56:18 2016 -0800
Committer: Jason Brown <jasedbrown@gmail.com>
Committed: Tue Dec 13 04:32:34 2016 -0800

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 .../cassandra/tools/nodetool/CompactionStats.java    | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5d8f6c64/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a65a147..4d8bb3a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.11
+ * Nodetool compactionstats fails with NullPointerException (CASSANDRA-13021)
  * Thread local pools never cleaned up (CASSANDRA-13033)
  * Set RPC_READY to false when draining or if a node is marked as shutdown (CASSANDRA-12781)
  * CQL often queries static columns unnecessarily (CASSANDRA-12768)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5d8f6c64/src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java b/src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java
index e57d2ee..bac23c2 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/CompactionStats.java
@@ -30,7 +30,6 @@ import org.apache.cassandra.db.compaction.CompactionManagerMBean;
 import org.apache.cassandra.db.compaction.OperationType;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.tools.NodeProbe;
-import org.apache.cassandra.tools.NodeTool;
 import org.apache.cassandra.tools.NodeTool.NodeToolCmd;
 
 @Command(name = "compactionstats", description = "Print statistics on compactions")
@@ -96,10 +95,14 @@ public class CompactionStats extends NodeToolCmd
         }
     }
 
-    private void addLine(List<String[]> lines, int[] columnSizes, String... columns)
{
-        lines.add(columns);
-        for (int i = 0; i < columns.length; i++) {
-            columnSizes[i] = Math.max(columnSizes[i], columns[i].length());
+    private void addLine(List<String[]> lines, int[] columnSizes, String... columns)
+    {
+        String[] newColumns = new String[columns.length];
+        for (int i = 0; i < columns.length; i++)
+        {
+            columnSizes[i] = Math.max(columnSizes[i], columns[i] != null ? columns[i].length()
: 1);
+            newColumns[i] = columns[i] != null ? columns[i] : "";
         }
+        lines.add(newColumns);
     }
-}
\ No newline at end of file
+}


Mime
View raw message