RFR: 8255074: sun.nio.fs.WindowsPath::getPathForWin32Calls synchronizes on String object

Alan Bateman alanb at openjdk.java.net
Wed Oct 21 09:27:58 UTC 2020


On Wed, 21 Oct 2020 09:07:32 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Hi all,
>> 
>> could you please review this small and trivial patch?
>> 
>> from JBS:
>> `sun.nio.fs.WindowsPath::getPathForWin32Calls` synchronizes on `path` field, which is a `String` object: 
>>         if (type != WindowsPathType.DRIVE_RELATIVE) { 
>>             synchronized (path) { 
>>                 pathForWin32Calls = new WeakReference<String>(resolved); 
>>             } 
>>         } 
>> this might lead to a deadlock, synchronizing on `this` is appropriate here.
>> 
>> testing:
>> * [x] tier1
>> * [x] `test/jdk/java/nio` on windows-x64
>
> src/java.base/windows/classes/sun/nio/fs/WindowsPath.java line 209:
> 
>> 207:         // of the VM)
>> 208:         if (type != WindowsPathType.DRIVE_RELATIVE) {
>> 209:             synchronized (this) {
> 
> To be honest, I cannot see why this `synchronized` block exists at all...

It's not strictly needed and could be removed.

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

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


More information about the nio-dev mailing list