JDK-4355074 : Remote exception duplicates information in printStackTrace()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.rmi
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2000-07-20
  • Updated: 2001-11-20
  • Resolved: 2000-11-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Relates :  
Description

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) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: merlin-beta INTEGRATED IN: merlin-beta VERIFIED IN: merlin-beta3
14-06-2004

WORK AROUND Name: skT45625 Date: 07/20/2000 None. ======================================================================
11-06-2004

EVALUATION Yes, this is annoying. It came about with the change to make RemoteException stack traces print the trace of the nested exception (if any), which provides more information. I suppose that this situation could be made better by coding RemoteException's printStackTrace(PrintStream ps) method like this: if (detail == null) { super.printStackTrace(ps); } else { synchronized (ps) { ps.print(getClass().getName() + ": nested exception is: \n\t"); detail.printStackTrace(ps); } } and likewise for the printStackTrace(PrintWriter pw) method. This should only invoke the nested exception's toString() method once, while preserving the original "look and feel" of RemoteException. peter.jones@East 2000-07-20 Actually, this bug has been incidentally fixed by the new general exception chaining mechanism that was added to java.lang.Throwable in Merlin (see 4209652). With the associated changes, java.rmi.RemoteException no longer overrides printStackTrace at all: Throwable now takes care of the nested exception stack trace printing in a much nicer fashion. peter.jones@East 2000-11-29
29-11-2000