RFR: 8264400: (fs) WindowsFileStore equality depends on how the FileStore was constructed

Brian Burkhalter bpb at openjdk.java.net
Tue Apr 6 21:38:30 UTC 2021


On Mon, 5 Apr 2021 17:19:35 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> I already have this information.
>> 
>> 1. `C:` - Win10 system drive
>> 
>> `Root: C:\
>> volName: System, fsName: NTFS, volSN: 1620920694, volType: 3`
>> 
>> 2. `E:` - CD drive (VirtualBox Guest Additions)
>> 
>> `Root: E:\
>> volName: VBox_GAs_6.1.18, fsName: CDFS, volSN: -1657170319, volType: 5`
>> 
>> 3. `Z:` - VirtualBox shared folder
>> 
>> `Root: Z:\
>> volName: VBOX_VirtualBox, fsName: VBoxSharedFolderFS, volSN: 16777221, volType:
>> 4`
>> 
>> 4. `\\BPB\Public` - Local share created for `C:\Users\Public`
>> 
>> `Root: \\BPB\Public\
>> volName: System, fsName: NTFS, volSN: 1620920694, volType: 4`
>> 
>> 5. `\\192.168.0.111\Shared` - "Remote" share of macOS host `/Users/Shared`
>> 
>> `Root: \\192.168.0.111\Shared\
>> volName: Macintosh HD - Data, fsName: NTFS, volSN: 0, volType: 4`
>
> I already tested with other cases but didn't include it:
> 
> Root: \\bpb\Public\
> volName: System, fsName: NTFS, volSN: 1620920694, volType: 4
> 
> Root: \\BPB\pUBLIC\
> volName: System, fsName: NTFS, volSN: 1620920694, volType: 4
> 
> Root: \\192.168.0.111\Shared\
> volName: Macintosh HD - Data, fsName: NTFS, volSN: 0, volType: 4
> 
> Root: \\192.168.0.111\shared\
> volName: Macintosh HD - Data, fsName: NTFS, volSN: 0, volType: 4
> 
> Good point about `hashCode()`.

If we want to constrain the case insensitive comparison to fixed drives, then this might work:
    @Override
    public boolean equals(Object ob) {
        if (ob == this)
            return true;
        if (!(ob instanceof WindowsFileStore))
            return false;
        WindowsFileStore other = (WindowsFileStore)ob;
        if (root.equals(other.root))
            return true;
        if (volType == DRIVE_FIXED && other.volumeType() == DRIVE_FIXED)
            return root.equalsIgnoreCase(other.root);
        return false;
    }

    @Override
    public int hashCode() {
        return volType == DRIVE_FIXED ?
            root.toLowerCase().hashCode() : root.hashCode();
    }

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

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


More information about the nio-dev mailing list