Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8025690

Default FileHandler constructor doesn't throw NullPointerException if pattern is empty and count > 1

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 5.0, 6, 7, 8, 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b34
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dfuchs Daniel Fuchs
                  Reporter:
                  psemenov Pavel Semenov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: