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

Brian Burkhalter bpb at openjdk.java.net
Wed Apr 7 18:35:51 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.

What do you intend by the `Locale.X` comment?

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

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


More information about the nio-dev mailing list