RFR: 8264400: (fs) WindowsFileStore equality depends on how the FileStore was constructed
Brian Burkhalter
bpb at openjdk.java.net
Wed Apr 7 21:54:24 UTC 2021
On Wed, 7 Apr 2021 11:29:29 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> 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();
>> }
>
>> If we want to constrain the case insensitive comparison to fixed drives, then this might work:
>
> Yes, although it would be good to extend this to the DRIVE_REMOTE and other cases too, but that requires being confident that it is correct (and I'm not sure we have enough information to say this yet).
>
> An initial change for the DRIVE_FIXED case is okay. It will mean using Locale.ROOT or Locale.US. Also the hash code will need to be cached.
(Commit message for 9260dfd intended `DRIVE_FIXED`, not `DRIVE_LOCAL`: inadvertently conflated with `MNT_LOCAL` on `macOS`.)
-------------
PR: https://git.openjdk.java.net/jdk/pull/3279
More information about the nio-dev
mailing list