From 559b17f71d3207158d34b1dd2414a531e362af20 Mon Sep 17 00:00:00 2001 From: David Capwell Date: Tue, 3 May 2022 14:59:55 -0700 Subject: [PATCH] nodetool enablefullquerylog can NPE when directory has no files patch by David Capwell; reviewed by Jon Meredith for CASSANDRA-17595 --- CHANGES.txt | 1 + src/java/org/apache/cassandra/utils/binlog/BinLog.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 050767a9438..131b0c980d4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.1 + * nodetool enablefullquerylog can NPE when directory has no files (CASSANDRA-17595) * Add auto_snapshot_ttl configuration (CASSANDRA-16790) * List snapshots of dropped tables (CASSANDRA-16843) * Add information whether sstables are dropped to SchemaChangeListener (CASSANDRA-17582) diff --git a/src/java/org/apache/cassandra/utils/binlog/BinLog.java b/src/java/org/apache/cassandra/utils/binlog/BinLog.java index a9bb55ac8d8..e2ae1ec09bb 100644 --- a/src/java/org/apache/cassandra/utils/binlog/BinLog.java +++ b/src/java/org/apache/cassandra/utils/binlog/BinLog.java @@ -486,9 +486,11 @@ private static Throwable deleteRecursively(File fileOrDirectory, Throwable accum { if (fileOrDirectory.isDirectory()) { - for (File f : fileOrDirectory.tryList()) + File[] files = fileOrDirectory.tryList(); + if (files != null) { - accumulate = FileUtils.deleteWithConfirm(f, accumulate); + for (File f : files) + accumulate = FileUtils.deleteWithConfirm(f, accumulate); } } return FileUtils.deleteWithConfirm(fileOrDirectory, accumulate);