Apache Lucene open-source search software
listFiles can return null if a different thread removes the dir concurrently (may happen in Solr tests),..
Dawid Weiss4dd09dfd0758
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.javaindex 71648c595f2..85e66ca30ab 100644--- a/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java+++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java@@ -120,14 +120,16 @@ public final class TestUtil {}private static LinkedHashSet<File> rm(LinkedHashSet<File> unremoved, File... locations) {- for (File location : locations) {- if (location != null && location.exists()) {- if (location.isDirectory()) {- rm(unremoved, location.listFiles());- }-- if (!location.delete()) {- unremoved.add(location);+ if (locations != null) {+ for (File location : locations) {+ if (location != null && location.exists()) {+ if (location.isDirectory()) {+ rm(unremoved, location.listFiles());+ }++ if (!location.delete()) {+ unremoved.add(location);+ }}}}