Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve exception readability in case a directory can't be deleted be…
…cause it still contains files Use suppressed exceptions rather than wrap the exception so that we get the primary cause first, then details. Also resolve files relative to their containing folders. Before: ``` java.io.IOException: [REDACTED]/target/tmp/j h16565971146678333138/users/Fred_10744520479289247763/config.xml at org.jvnet.hudson.test.TemporaryDirectoryAllocator.delete(TemporaryDirectoryAllocator.java:144) at org.jvnet.hudson.test.TemporaryDirectoryAllocator.delete(TemporaryDirectoryAllocator.java:131) at org.jvnet.hudson.test.TemporaryDirectoryAllocator.delete(TemporaryDirectoryAllocator.java:131) at org.jvnet.hudson.test.TemporaryDirectoryAllocator.dispose(TemporaryDirectoryAllocator.java:99) at org.jvnet.hudson.test.TestEnvironment.dispose(TestEnvironment.java:84) at org.jvnet.hudson.test.JenkinsRule.after(JenkinsRule.java:527) at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:665) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: java.nio.file.DirectoryNotEmptyException: [REDACTED]/target/tmp/j h16565971146678333138/users/Fred_10744520479289247763 at java.base/sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:246) at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:110) at java.base/java.nio.file.Files.deleteIfExists(Files.java:1191) at org.jvnet.hudson.test.TemporaryDirectoryAllocator.delete(TemporaryDirectoryAllocator.java:141) ... 8 more ``` After: ``` java.nio.file.DirectoryNotEmptyException: [REDACTED]/target/tmp/j h16565971146678333138/users/Fred_10744520479289247763 at java.base/sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:289) at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:109) at java.base/java.nio.file.Files.deleteIfExists(Files.java:1191) at org.jvnet.hudson.test.TemporaryDirectoryAllocator.delete(TemporaryDirectoryAllocator.java:142) at org.jvnet.hudson.test.TemporaryDirectoryAllocator.dispose(TemporaryDirectoryAllocator.java:100) at org.jvnet.hudson.test.TestEnvironment.dispose(TestEnvironment.java:84) at org.jvnet.hudson.test.JenkinsRule.after(JenkinsRule.java:586) at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:724) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.lang.Thread.run(Thread.java:1583) Suppressed: java.io.IOException: These files still exist : config.xml at org.jvnet.hudson.test.TemporaryDirectoryAllocator.delete(TemporaryDirectoryAllocator.java:146) ... 6 more ```
- Loading branch information