-
Bug
-
Resolution: Fixed
-
P4
-
5.0, 6, 7, 8, 9
-
b34
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8084402 | emb-9 | Daniel Fuchs | P4 | Resolved | Fixed | team |
FileHandler constructor NullPointerException - if pattern property is an empty String, but if count > 1
exception won't be thrown.
Example Main.java:
import java.util.logging.FileHandler;
public class Main {
public static void main(String[] args) {
FileHandler fh = null;
try {
fh = new FileHandler();
System.out.println("fail");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fh != null) {
fh.close();
}
}
}
}
property file: pr.properties:
java.util.logging.FileHandler.count = 2
java.util.logging.FileHandler.pattern=
Run:
jdk1.7.0_45b09\bin\java.exe -Djava.util.logging.config.file=pr.properties Main
fail
file with name .0 will be created in the current folder
If we change pr.properties:
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.pattern=
and run again:
jdk1.7.0_45b09\bin\java.exe -Djava.util.logging.config.file=pr.properties Main
java.lang.NullPointerException
at java.util.logging.FileHandler.openFiles(FileHandler.java:392)
at java.util.logging.FileHandler.<init>(FileHandler.java:225)
at Main.main(Main.java:8)
NPE was thrown as expected.
exception won't be thrown.
Example Main.java:
import java.util.logging.FileHandler;
public class Main {
public static void main(String[] args) {
FileHandler fh = null;
try {
fh = new FileHandler();
System.out.println("fail");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fh != null) {
fh.close();
}
}
}
}
property file: pr.properties:
java.util.logging.FileHandler.count = 2
java.util.logging.FileHandler.pattern=
Run:
jdk1.7.0_45b09\bin\java.exe -Djava.util.logging.config.file=pr.properties Main
fail
file with name .0 will be created in the current folder
If we change pr.properties:
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.pattern=
and run again:
jdk1.7.0_45b09\bin\java.exe -Djava.util.logging.config.file=pr.properties Main
java.lang.NullPointerException
at java.util.logging.FileHandler.openFiles(FileHandler.java:392)
at java.util.logging.FileHandler.<init>(FileHandler.java:225)
at Main.main(Main.java:8)
NPE was thrown as expected.
- backported by
-
JDK-8084402 Default FileHandler constructor doesn't throw NullPointerException if pattern is empty and count > 1
-
- Resolved
-