You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sa...@apache.org on 2020/11/23 15:36:59 UTC

[cassandra] branch cassandra-3.0 updated: Avoid potential NPE in JVMStabilityInspector

This is an automated email from the ASF dual-hosted git repository.

samt pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
     new 068d87a  Avoid potential NPE in JVMStabilityInspector
068d87a is described below

commit 068d87acfbdf384f883ca17895c40a7a36a507b0
Author: Sam Tunnicliffe <sa...@beobal.com>
AuthorDate: Fri Nov 20 15:51:20 2020 +0000

    Avoid potential NPE in JVMStabilityInspector
    
    Patch by Sam Tunnicliffe; reviewed by David Capwell for CASSANDRA-16294
---
 CHANGES.txt                                                      | 1 +
 src/java/org/apache/cassandra/utils/JVMStabilityInspector.java   | 2 +-
 .../org/apache/cassandra/utils/JVMStabilityInspectorTest.java    | 9 +++++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 7aecefa..546fd98 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.24:
+ * Avoid potential NPE in JVMStabilityInspector (CASSANDRA-16294)
  * Improved check of num_tokens against the length of initial_token (CASSANDRA-14477)
  * Fix a race condition on ColumnFamilyStore and TableMetrics (CASSANDRA-16228)
  * Remove the SEPExecutor blocking behavior (CASSANDRA-16186)
diff --git a/src/java/org/apache/cassandra/utils/JVMStabilityInspector.java b/src/java/org/apache/cassandra/utils/JVMStabilityInspector.java
index b018e04..798949f 100644
--- a/src/java/org/apache/cassandra/utils/JVMStabilityInspector.java
+++ b/src/java/org/apache/cassandra/utils/JVMStabilityInspector.java
@@ -107,7 +107,7 @@ public final class JVMStabilityInspector
 
         // Check for file handle exhaustion
         if (t instanceof FileNotFoundException || t instanceof SocketException)
-            if (t.getMessage().contains("Too many open files"))
+            if (t.getMessage() != null && t.getMessage().contains("Too many open files"))
                 isUnstable = true;
 
         if (isUnstable)
diff --git a/test/unit/org/apache/cassandra/utils/JVMStabilityInspectorTest.java b/test/unit/org/apache/cassandra/utils/JVMStabilityInspectorTest.java
index ecb2955..1a2a864 100644
--- a/test/unit/org/apache/cassandra/utils/JVMStabilityInspectorTest.java
+++ b/test/unit/org/apache/cassandra/utils/JVMStabilityInspectorTest.java
@@ -118,12 +118,21 @@ public class JVMStabilityInspectorTest
             assertFalse(killerForTests.wasKilled());
 
             killerForTests.reset();
+            JVMStabilityInspector.inspectThrowable(new SocketException());
+            assertFalse(killerForTests.wasKilled());
+
+            killerForTests.reset();
+            JVMStabilityInspector.inspectThrowable(new FileNotFoundException());
+            assertFalse(killerForTests.wasKilled());
+
+            killerForTests.reset();
             JVMStabilityInspector.inspectThrowable(new SocketException("Too many open files"));
             assertTrue(killerForTests.wasKilled());
 
             killerForTests.reset();
             JVMStabilityInspector.inspectCommitLogThrowable(new FileNotFoundException("Too many open files"));
             assertTrue(killerForTests.wasKilled());
+
         }
         finally
         {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org