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

Aleksey Shipilev shade at openjdk.java.net
Wed Oct 21 09:09:56 UTC 2020


On Tue, 20 Oct 2020 21:50:38 GMT, Igor Ignatyev <iignatyev 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...

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

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


More information about the nio-dev mailing list