RFR: 8263898: (fs) Files.newOutputStream on the "NUL" special device throws FileSystemException: "nul: Incorrect function" (win) [v3]
Alan Bateman
alanb at openjdk.java.net
Fri Mar 26 07:06:27 UTC 2021
On Thu, 25 Mar 2021 22:16:46 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> This request proposes to change the native method `WindowsNativeDispatcher.SetEndOfFile()` to succeed even if the Windows function `SetEndOfFile()` returns zero if `GetFileSizeEx()` called on the handle succeeds and reveals a file size of zero.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove whitespace
test/jdk/java/nio/file/Files/NullDevice.java line 44:
> 42: }
> 43: }
> 44: }
The updated changes to the Windows file system provider looks good. Have you checked that WindowsNativeDispatcher.GetFileSizeEx returns the correct size for a non-zero length file? (asking about that because it won't be exercised by the any of the tests and we might want to use it in order places).
The test name is "NullDevice" but it actually tests "nul" :-) so maybe it should be renamed. Files.newOutputStream is just one way to open the NUL device for writing. Would be good to also test opening it for wring without the TRUNCATE_EXISTING operation. I think we should do reading while we are there.
You can use Path.of("nul") to avoid first creating a java.io.File and using toPath.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3183
More information about the nio-dev
mailing list