RFR: 8059269 - FileHandler may throw NPE if pattern is a simple name and the lock file already exists

Daniel Fuchs daniel.fuchs at oracle.com
Fri Sep 26 18:33:44 UTC 2014


Hi,

Please find below a patch for [1]

8059269: FileHandler may throw NPE if pattern is a simple name and
          the lock file already exists

[1] https://bugs.openjdk.java.net/browse/JDK-8059269

The webrev is here:
http://cr.openjdk.java.net/~dfuchs/webrev_8059269/webrev.00


This is a regression which I unfortunately introduced with my
patch for JDK-8048020 - and which I stumbled upon while writing
another test (which should have failed but didn't).

It happens in the uncommon case where:

  1. a lock file for the given name pattern already exists, and
    hasn't been created by another FileHandler in the same VM, and
  2. the file name pattern is a simple file name (not composite - that
    is, it doesn't contain any file separator).

In that case, FileHandler will attempt to reuse the existing
lock file, but it will first check whether the directory
in which the lock file should be created is writable, which it does
by calling Files.isWritable(lockFilePath.getParent()). We want to
check whether the directory is writable because there's no point
in locking the existing lock file if we can't create
any new file in that directory.

Unfortunately, lockFilePath.getParent() returns null if the file name
is simple, and a NullPointerException is thrown.


best regards,

-- daniel



More information about the core-libs-dev mailing list