Index: working_classlib/modules/jndi/src/main/java/javax/naming/NamingException.java
===================================================================
--- working_classlib/modules/jndi/src/main/java/javax/naming/NamingException.java (revision 486436)
+++ working_classlib/modules/jndi/src/main/java/javax/naming/NamingException.java (working copy)
@@ -270,69 +270,6 @@
* Methods override parent class Exception
* -------------------------------------------------------------------
*/
-
- /**
- * If there is a root exception associated with this
- * NamingException then first print the class name and message
- * of this NamingException, followed by the text
- * ". The stack trace of the root exception is: ", followed by the stack
- * trace of the exception which caused this exception.
- *
- * If there is no root exception associated with this
- * NamingException then print the stack trace of this
- * NamingException.
- * The output from this goes to System.err.
printStackTrace() except the output
- * goes to the specified PrintStream p.
- *
- * @param p the PrintStream to which the stack trace is
- * printed.
- */
- @Override
- public void printStackTrace(PrintStream p) {
- if (null != rootException) {
- p.print(super.toString());
- // jndi.err.00=. The stack trace of the root exception is:
- p.print(Messages.getString("jndi.err.00")); //$NON-NLS-1$
- rootException.printStackTrace(p);
- } else {
- super.printStackTrace(p);
- }
- }
-
- /**
- * Performs the same as printStackTrace() except the output
- * goes to the specified PrintWriter p.
- *
- * @param p the PrintWrite to which the stack trace is
- * printed.
- */
- @Override
- public void printStackTrace(PrintWriter p) {
- if (null != rootException) {
- p.print(super.toString());
- // jndi.err.00=. The stack trace of the root exception is:
- p.print(Messages.getString("jndi.err.00")); //$NON-NLS-1$
- rootException.printStackTrace(p);
- } else {
- super.printStackTrace(p);
- }
- }
/*
* (non-Javadoc)
@@ -340,7 +277,7 @@
*/
@Override
public Throwable getCause() {
- return super.getCause();
+ return getRootCause();
}
/*
@@ -349,7 +286,9 @@
*/
@Override
public Throwable initCause(Throwable cause) {
- return super.initCause(cause);
+ super.initCause(cause);
+ rootException = cause;
+ return this;
}
/*
@@ -388,7 +327,4 @@
}
return sb.toString();
}
-
}
-
-
Index: working_classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NamingExceptionTest.java
===================================================================
--- working_classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NamingExceptionTest.java (revision 486436)
+++ working_classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/NamingExceptionTest.java (working copy)
@@ -237,19 +237,19 @@
ex.setRootCause(new Exception(trace2));
ex.printStackTrace();
str = new String(bStream.toByteArray());
- assertTrue(str.indexOf(trace1) < 0);
+ assertTrue(str.indexOf(trace1) > 0);
assertTrue(str.indexOf(trace2) > 0);
bStream.reset();
ex.printStackTrace(stream);
str = new String(bStream.toByteArray());
- assertTrue(str.indexOf(trace1) < 0);
+ assertTrue(str.indexOf(trace1) > 0);
assertTrue(str.indexOf(trace2) > 0);
bStream.reset();
ex.printStackTrace(new PrintWriter(stream, true));
str = new String(bStream.toByteArray());
- assertTrue(str.indexOf(trace1) < 0);
+ assertTrue(str.indexOf(trace1) > 0);
assertTrue(str.indexOf(trace2) > 0);
bStream.reset();