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

LOGGING APIs: SimpleFormatter ignores getThrownBackTrace method

XMLWordPrintable

    • beta
    • generic
    • generic
    • Verified



      Name: elR10090 Date: 09/20/2000



      Logging APIs specification (draft 0.49) states:

      "The "thrown" property is transmitted as part of the serialized form,
      but because the Throwable class does not preserve stack frame information
      across serialization, the stack frame info will be lost from the "thrown"
      object. However, during serialization the writeObject method will ensure
      that a String version of the stack trace is serialized, and that String
      will be available through the getThrownBackTrace method."

      This is fragment of SimpleFormatter.java (1.6 00/08/31):

          public synchronized String format(LogRecord record) {

              ... (skipped)

              if (record.getThrown() != null) {
                  try {
                      StringWriter sw = new StringWriter();
                      PrintWriter pw = new PrintWriter(sw);
                      record.getThrown().printStackTrace(pw);
                      pw.close();
                      sb.append(sw.toString());
                  } catch (Exception ex) {
                  }
              }
              return sb.toString();
          }

      As we see in the fragment, SimpleFormatter tries to build trace
      of the "thrown" property by its own means instead of calling
      record.getThrownBackTrace(). This produces empty "back trace"
      for the record being put across serialization even if the record
      has non-empty one before it.
       
      ======================================================================

      Name: elR10090 Date: 02/01/2001


      This bug affects the following testbase_nsk test:
          nsk/logging/LogRecord/Serialization/serializ002


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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: