diff --git a/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java b/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java index 5d3b50219..818a992aa 100644 --- a/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java +++ b/src/main/java/org/jvnet/hudson/test/TemporaryDirectoryAllocator.java @@ -36,6 +36,7 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.lang.StringUtils; /** * Allocates temporary directories and cleans it up at the end. @@ -140,9 +141,11 @@ private void delete(Path p) throws IOException { } Files.deleteIfExists(p); } catch (DirectoryNotEmptyException x) { + String pathString = p.toString(); try (Stream children = Files.list(p)) { - throw new IOException(children.map(Path::toString).collect(Collectors.joining(" ")), x); + x.addSuppressed(new IOException("These files still exist : " + children.map(Path::toString).map(s -> StringUtils.removeStart(s, pathString + File.separator)).collect(Collectors.joining(", ")))); } + throw x; } }