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

java.util.logging.Logger.throwing() is calling doLog() without testing offValue

XMLWordPrintable



      Name: rmT116609 Date: 10/22/2003


      FULL PRODUCT VERSION :
      C:\j2sdk1.4.2_02\bin>java -version
      java version "1.4.2_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

      FULL OS VERSION :
      Windows XP Professional 2002 SP-1

      A DESCRIPTION OF THE PROBLEM :
      The throwing method doesn't check levelValue against offValue before calling the doLog() method as it should do :

          public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
      if (Level.FINER.intValue() < levelValue) {
      return;
      }
      LogRecord lr = new LogRecord(Level.FINER, "THROW");
      lr.setSourceClassName(sourceClass);
      lr.setSourceMethodName(sourceMethod);
      lr.setThrown(thrown);
      doLog(lr);
          }

      The corrected code should be :

          public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
      //if (Level.FINER.intValue() < levelValue) { // INCORRECT
      if (Level.FINER.intValue() < levelValue || levelValue == offValue) { // CORRECTED
      return;
      }
      LogRecord lr = new LogRecord(Level.FINER, "THROW");
      lr.setSourceClassName(sourceClass);
      lr.setSourceMethodName(sourceMethod);
      lr.setThrown(thrown);
      doLog(lr);
          }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      No need to run the code to reproduce the issue. Reading all doLog() call contexts in Logger.java, the additional check is simply missing in Logger.throwing(), period.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would have expected that Logger.throwing() doesn't log anything if the current Logger's level is Level.OFF.
      ACTUAL -
      Logger.throwing() will create a log entry even if its level is Level.OFF.

      REPRODUCIBILITY :
      This bug can be reproduced always.
      (Incident Review ID: 217144)
      ======================================================================

            caustinsunw Calvin Austin (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: