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)
======================================================================
- relates to
-
JDK-4209652 Put recursive exception handling (ala InvocationTargetException) into Throwable!
-
- Resolved
-