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

NPE when using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger

    Details

    • Subcomponent:
    • Resolved In Build:
      b98
    • OS:
      os_x
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version " 1.7.0_25 "
        Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)


        ADDITIONAL OS VERSION INFORMATION :
        Occurs on multiple Platforms reproduced on OS X and Windows

        A DESCRIPTION OF THE PROBLEM :
        When using Logger.getAnonymousLogger or LogManager.getLogManager().getLogger in an applet a NPE occurs on the second load of the applet in the browser session.

        If the browser is restarted the applet loads fine until the next reload.

        REGRESSION: I could only choose 7 update 25 or 7 update 40 in the regression drop down. The issue only occurs since 7 update 25 but not in 7 update 21

        REGRESSION. Last worked in version 7u25

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Create an applet from the code below.
        2. Load it in a browser
        3. Reload the page with the applet

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No NPE on reload
        ACTUAL -
        NPE on reload

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        java.lang.NullPointerException
        at java.util.logging.Logger.doSetParent(Logger.java:1593)
        at java.util.logging.Logger.getAnonymousLogger(Logger.java:534)
        at java.util.logging.Logger.getAnonymousLogger(Logger.java:495)
        at TestApplet.init(TestApplet.java:12)
        at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:724)

        AND

        java.lang.NullPointerException
        at java.util.logging.Logger.setParent(Logger.java:1558)
        at TestApplet$EditorLogger.<init>(TestApplet.java:30)
        at TestApplet.init(TestApplet.java:18)
        at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:724)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.util.logging.LogManager;
        import java.util.logging.Logger;

        import javax.swing.JApplet;

        public class TestApplet extends JApplet {
            
            private EditorLogger editorLogger;
            public void init() {
                
                try {
                    Logger logger = Logger.getAnonymousLogger();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                
                try {
                    this.editorLogger = new EditorLogger();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            
            public class EditorLogger extends Logger {
                
                public EditorLogger() {
                    super(null, null);
                    System.out.println( " LogManager: " +LogManager.getLogManager());
                    System.out.println( " getLogger: " +LogManager.getLogManager().getLogger( " " ));
                    setParent(LogManager.getLogManager().getLogger( " " ));
                }
            }
        }

        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  dfuchs Daniel Fuchs
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: