On Fri, 15 Mar 2024 11:17:08 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> test/jdk/javax/swing/plaf/basic/BasicDirectoryModel/ConcurrentModification.java >> line 211: >> >>> 209: private static void deleteFile(final Path file) { >>> 210: try { >>> 211: Files.delete(file); >> >> Should we try to delete all files first and then throw an exception if any? > > I do try to remove all the files: > > https://github.com/openjdk/jdk/blob/0d6be7a4e4368ea67382af4321b9483236276e5a/test/jdk/javax/swing/plaf/basic/BasicDirectoryModel/ConcurrentModification.java#L115-L120 > > https://github.com/openjdk/jdk/blob/0d6be7a4e4368ea67382af4321b9483236276e5a/test/jdk/javax/swing/plaf/basic/BasicDirectoryModel/ConcurrentModification.java#L202-L215 > > Probably, this can be chained via `handleException`. On the other hand, I > don't want to fail the test if cleaning up the files fails. However, now an > exception thrown from the `finally` block will override any exception thrown > from the test code, which is a bad thing, so I'll need to reconsider > exception handling during clean-up. > > If test fails to clean up the files it created, jtreg will remove them. It is > the reason why I use the current directory as the base, which is the > `scratch` directory when run in jtreg. I updated the code to avoid throwing `IOException` from cleaning up code. If an exception occurs, its stack trace is printed to `stderr`. The test will not fail if cleaning up the files fails. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/18109#discussion_r1530772076