src/java.logging/share/classes/java/util/logging/FileHandler.java
Print this page
@@ -400,10 +400,18 @@
this.count = count;
this.append = append;
openFiles();
}
+ private boolean isParentWritable(Path path) {
+ Path parent = path.getParent();
+ if (parent == null) {
+ parent = path.toAbsolutePath().getParent();
+ }
+ return parent != null && Files.isWritable(parent);
+ }
+
/**
* Open the set of output files, based on the configured
* instance variables.
*/
private void openFiles() throws IOException {
@@ -456,11 +464,11 @@
// execution. Reuse it - but only if we can actually
// write to its directory.
// Note that this is a situation that may happen,
// but not too frequently.
if (Files.isRegularFile(lockFilePath, LinkOption.NOFOLLOW_LINKS)
- && Files.isWritable(lockFilePath.getParent())) {
+ && isParentWritable(lockFilePath)) {
try {
channel = FileChannel.open(lockFilePath,
WRITE, APPEND);
} catch (NoSuchFileException x) {
// Race condition - retry once, and if that