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

java.util.logging.Formatter.get[Head|Tail]: no NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • sparc
    • solaris_7



      Name: sdR10048 Date: 11/10/2002


      -- T.java --
      import java.util.logging.Formatter;
      import java.util.logging.LogRecord;

      class MyFormatter extends Formatter {
          public MyFormatter() {
          }
          public String format(LogRecord record) {
              return "";
          }
      }

      class T {
          public static void main(String args[]) {
              MyFormatter formatter = new MyFormatter();
              formatter.getHead(null);
              formatter.getTail(null);
              System.out.println("No NPE.");
          }
      }
      -- Output --
      No NPE.

      ------------
      Javadoc says:

      (1)

      public String getHead(Handler h)

      Return the header string for a set of formatted records.

      This base class returns an empty string, but this may be overriden by
      subclasses.

      Parameters:
          h - The target handler.
      Returns:
          header string

      (2)

      doc/api/java/util/logging/package-summary.html

      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 config, entering, exiting, fine,
      finer, finest, log, logp, logrb, severe, throwing, and warning
      methods) will accept null values for all arguments except for the
      initial Level argument (if any).

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

            ghamiltosunw Graham Hamilton (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: