JDK-8059269 : FileHandler may throw NPE if pattern is a simple name and the lock file already exists
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Affected Version: 8u40,9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-09-26
  • Updated: 2015-06-04
  • Resolved: 2014-09-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b34Fixed
Related Reports
Relates :  
Description
This is a regression introduced by JDK-8048020 - which might happen in the uncommon case where: pattern is a simple name (not a full path), and the .lck file already exists on disk (and hasn't been created by another FileHandler in the same VM).

In that case, we will check whether we have write permission in the directory in which the lck file is present. The catch is that if the file name is a simple name (not composed), then Path.getParentPath() will return null, and Files.isWritable() will throw NPE.

Exception in thread "main" java.lang.NullPointerException
	at java.nio.file.Files.provider(Files.java:96)
	at java.nio.file.Files.isAccessible(Files.java:2454)
	at java.nio.file.Files.isWritable(Files.java:2520)
	at java.util.logging.FileHandler.openFiles(FileHandler.java:466)

Comments
Adding matching for aurora: RULE java/util/logging/FileHandlerPath.java Exception java.lang.NullPointerException
15-10-2014

review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-September/028918.html
30-09-2014

work around: transform the pattern into a composite path. For instance, if the pattern is the simple name "foo", you could use pattern = new File(System.getProperty("user.dir"), "foo").toString(); instead - as that should point to the same file.
26-09-2014