Avoid potential NPE in JVMStabilityInspector

Patch by Sam Tunnicliffe; reviewed by David Capwell for CASSANDRA-16294
This commit is contained in:
Sam Tunnicliffe 2020-11-20 15:51:20 +00:00
parent bfd5d20a13
commit 068d87acfb
3 changed files with 11 additions and 1 deletions

View File

@ -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)

View File

@ -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)

View File

@ -117,6 +117,14 @@ public class JVMStabilityInspectorTest
JVMStabilityInspector.inspectThrowable(new FileNotFoundException("Also should not fail"));
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());
@ -124,6 +132,7 @@ public class JVMStabilityInspectorTest
killerForTests.reset();
JVMStabilityInspector.inspectCommitLogThrowable(new FileNotFoundException("Too many open files"));
assertTrue(killerForTests.wasKilled());
}
finally
{