diff --git a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java index ecf0b31934c..6f2fabd5188 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -450,7 +450,18 @@ public final class NodeEnvironment implements Closeable { IOUtils.rm(customLocation); } logger.trace("deleted shard {} directory, paths: [{}]", shardId, paths); - assert FileSystemUtils.exists(paths) == false; + assert assertPathsDoNotExist(paths); + } + + private static boolean assertPathsDoNotExist(final Path[] paths) { + Set existingPaths = new HashSet<>(); + for (Path path : paths) { + if (FileSystemUtils.exists(paths)) { + existingPaths.add(path); + } + } + assert existingPaths.size() == 0 : "Paths exist that should have been deleted: " + existingPaths; + return existingPaths.size() == 0; } private boolean isShardLocked(ShardId id) {