RFR: 8305072: Win32ShellFolder2.compareTo is inconsistent [v2]
Phil Race
prr at openjdk.org
Tue Mar 12 19:38:14 UTC 2024
On Tue, 5 Mar 2024 17:40:01 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> The implementation of `Win32ShellFolder2.compareTo` is inconsistent: there are cases where
>> `a < b & b < c but a == c`
>> which *violates its general contract*.
>>
>> In particular, it happens for the personal folder (*Documents*) if it is listed *twice*: as a special and as a regular folder.
>>
>> The evaluation performed by the submitter of the bug provided enough details to create a test, reproduce the problem and finally resolve it.
>>
>> Without the fix, the regression test always fails:
>>
>> a < b & b < c but a >= c
>> where
>> a = C:\Users<user>\Documents(true)
>> b = C:\Users<user>(false)
>> c = C:\Users<user>\Documents(false)
>>
>> as well as for the reverse case: `a > b & b > c`.
>>
>> How it is possible to have the same folder in a list of files twice remains unknown. I believe it is another bug in JDK, however, no one has been able to reproduce it so far.
>
> Alexey Ivanov has updated the pull request incrementally with one additional commit since the last revision:
>
> Handle fakePersonal on Windows 10
>
> The desktop folder on Windows 10 does not include
> the Personal (Documents) folder.
src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java line 525:
> 523: boolean special2 = sf2.isSpecial();
> 524:
> 525: if (special1 && special2) {
Could you please say something on how/why this change solves it ?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18126#discussion_r1522020052
More information about the client-libs-dev
mailing list