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

If Logger.getHandlers() returns null, Logger.log(LogRecord) throws NPE

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P3
    • None
    • 7
    • tools

    Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      If the Logger class is subclassed, and getHandlers() returns a null, Logger.log(LogRecord record) throws an NPE due to this line:

                  for (Handler handler : logger.getHandlers()) {

      In Java 6 and prior, a null pointer check was performed.

          Handler targets[] = logger.getHandlers();
          if (targets != null) {
              for (int i = 0; i < targets.length; i++) {

      The API doc is not specific about wheher it is allowed. Since it was allowed in Java6 and prior, the application developer I Imagine assumed that it is allowed.

      This causes problems for legacy applications upgrading from Java 6 to Java 7. Without the source for that application, upgrading to java 7 is not possible, as it crashes at initialization (in my case).

      REGRESSION. Last worked in version 6u31


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
        Fix your logger to return an empty array.

      Attachments

        Activity

          People

            igerasim Ivan Gerasimov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: