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

Remote exception duplicates information in printStackTrace()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • core-libs
    • beta
    • generic
    • generic
    • Verified



      Name: skT45625 Date: 07/20/2000


      src_stage:/weblogic/dev/src_stage/tools/weblogic/qa/tests> java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Server VM (build 2.0fcs-E, mixed mode)

      This isn't a serious bug, but it is ugly. When you do a printStackTrace on a
      RemoteException which contains a non-null detail field (a nested exception) the
      toString() of the detail is printed twice.

      RemoteException: ; nested exception is:
           java.io.IOException: Some message here
      java.io.IOException: Some message here
      Stacktrace here.

      The problem lies in the combination getMessage() and printStackTrace() methods
      RemoteException and the toString(), getLocalizedMessage() and printStackTrace()
      methods of Throwable. Secifically:

      RemoteException.printStackTrace() does a println(this) which results in
      this.toString() being called.

        Throwable.toString() does a this.getLocalizedMessage(), which in turn does
        a this.getMessage().

          RemoteException.getMessage() calls detail.toString().

            Throwable.toString() goes through the above process again.

          getMessage() returns
       
        toString() returns

      RemoteException.printStackTrace() calls printStackTrace on the detail.

        Throwable.printStackTrace() does a println(this) which causes this.toString()
        to be called. At this point detail.toString() has been printed twice.
      (Review ID: 107196)
      ======================================================================

            peterjones Peter Jones (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: