RFR: 8272964: java/nio/file/Files/InterruptCopy.java fails with java.lang.RuntimeException: Copy was not interrupted

Brian Burkhalter bpb at openjdk.java.net
Thu Aug 26 02:56:27 UTC 2021


On Wed, 25 Aug 2021 23:37:50 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> In the interrupt case, if the copy does not throw an `IOException`, rather than using the copy duration versus a threshold as the criterion for failure, instead check whether the target file does **not** exist, and if it does not, then make the test fail as this would indicate that the copy was in fact interrupted but did not throw an exception in response.

My testing showed that if the interrupt is set on the main thread, the copy thread, before the copy actually starts, then the interrupt is missed and the copy runs to completion.

As for the `Files.notExists(target)` loop, I tried that in the previous attempt to fix this issue and it appeared that on Windows this call is too slow to use in this context and does not fix the problem.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5260


More information about the nio-dev mailing list