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

java.util.logging.Logger.getLogger(string, null) does not throw NPE

XMLWordPrintable



      Name: sdR10048 Date: 10/07/2003


      Filed By : SPB JCK team (###@###.###)
      JDK : java full version "1.5.0-beta-b22"
      JCK : 1.5
      Platform[s] : Solaris
      switch/Mode :
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test [s] :
      api/java_util/logging/Logger/index.html#GetLogger[Logger0200]
      (will be in WS soon, please see mini demo)

      Specification excerpt:
      ======================
      --------- J2SE API spec v.1.5 ---------
      ...
      public static Logger getLogger(String name,
                                     String resourceBundleName)
      Find or create a logger for a named subsystem. If a logger has already been created with the given name it is returned. Otherwise a new logger is created.

      If a new logger is created its log level will be configured based on the LogManager and it will configured to also send logging output to its parent loggers Handlers. It will be registered in the LogManager global namespace.

      If the named Logger already exists and does not yet have a localization resource bundle then the given resource bundle name is used. If the named Logger already exists and has a different resource bundle name then an IllegalArgumentException is thrown.

      Parameters:
      name - A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as java.net or javax.swing
      resourceBundleName - name of ResourceBundle to be used for localizing messages for this logger.
      Returns:
      a suitable Logger
      Throws:
      MissingResourceException - if the named ResourceBundle cannot be found.
      IllegalArgumentException - if the Logger already exists and uses a different resource bundle name.
      ...
      ---------- end-of-excerpt ---------------

      Problem description
      ===================
      The designated method does not throw NPE in case input param
      resourceBundleName == null. And that does not fit to current spec.
      See package level spec:

      Null Pointers

      In general, unless otherwise noted in the javadoc, methods and
      contructors will throw NullPointerException if passed a null argument.
      The one broad exception to this rule is that the logging convenience
      methods in the Logger class (the log, logp, log, severe, warning, config,
      fine, finer, and finest methods) will accept null values for all arguments
      except for the initial Level argument (if any).
          
      Minimized test:
      ===============
      ------- T.java -------
      import java.util.logging.*;

      public class T {
          public static void main(String[] args) {
              Logger.getLogger("THE TEST LOGGER", null);
          }
      }

      ------- end-of-T.java -------

      Minimized test output:
      ======================
      <NOT OUTPUT>


      ======================================================================

            caustinsunw Calvin Austin (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: