Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception readability in case a directory can't be deleted because it still contains files #814

Merged
merged 1 commit into from
Aug 13, 2024

Commits on Aug 13, 2024

  1. 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
    ```
    Vlatombe committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    3b56598 View commit details
    Browse the repository at this point in the history