From 4dd09dfd0758f84d2eaef31ba4fc0cfbd4470895 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Fri, 30 May 2014 08:53:13 +0000 Subject: [PATCH] listFiles can return null if a different thread removes the dir concurrently (may happen in Solr tests),.. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1598499 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/util/TestUtil.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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.java index 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 rm(LinkedHashSet 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); + } } } }