RFR: 8264400: (fs) WindowsFileStore equality depends on how the FileStore was constructed [v3]
Alan Bateman
alanb at openjdk.java.net
Thu Apr 8 16:24:15 UTC 2021
On Thu, 8 Apr 2021 16:15:23 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Please consider this change to make `sun.nio.fs.WindowsFileStore.equals()` return `true` if the root strings of the two objects are equal under case insensitive comparison, and the two `WindowsFileStore`s have the same volume information.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8264400: Remove hasHashCode and race on hashCode == 0
src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java line 234:
> 232: return supportsFileAttributeView(FileOwnerAttributeView.class);
> 233: if (name.equals("user"))
> 234: return supportsFileAttributeView(UserDefinedFileAttributeView.class); return false;
Can you revert this change, it's not part of the fix and it makes this method harder to maintain.
src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java line 241:
> 239: if (ob == this)
> 240: return true;
> 241: if (!(ob instanceof WindowsFileStore))
We can change this to
if (ob instanced WindowsFileStore other) { ... } and it will avoid the cast.
src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java line 254:
> 252: public int hashCode() {
> 253: if (hashCode == 0) { // Don't care about race
> 254: hashCode = volType == DRIVE_FIXED ?
minor nit but would be a bit easier to read if changed to
hashCode = (volType == DRIVE_FIXED) ? ...
test/jdk/java/nio/file/FileStore/Basic.java line 89:
> 87: FileSystem fs = FileSystems.getDefault();
> 88: FileStore upper = Files.getFileStore(fs.getPath("C:\\"));
> 89: FileStore lower = Files.getFileStore(fs.getPath("c:\\"));
Path.of("c:\") can be used if you want.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3279
More information about the nio-dev
mailing list