harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2638) [luni][jndi] javax.naming.NamingException.printStackTrace() output should contain the output of NamingException.toString()
Date Tue, 12 Dec 2006 13:07:22 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-2638?page=comments#action_12457697 ] 
Vasily Zakharov commented on HARMONY-2638:

I wonder why our implementation overrides that method at all.
In RI, as you may see in JavaDoc, NamingException doesn't override printStackTrace() methods.

Also, it looks like the following spec statement is violated:
"This exception has been retrofitted to conform to the general purpose exception-chaining
mechanism. The root exception (or root cause) is the same object as the cause returned by
the Throwable.getCause() method."

It means that the same field must be used for getRootCause(), setRootCause(), getCause() and
initCause() methods, and that is not true for our implementation. The overridden getCause()
and initCause() do nothing in fact.

Looks like this class requires essential cleanup.

> [luni][jndi] javax.naming.NamingException.printStackTrace() output should contain the
output of NamingException.toString()
> --------------------------------------------------------------------------------------------------------------------------
>                 Key: HARMONY-2638
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2638
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Anton Ivanov
>            Priority: Minor
> It is said in the specification of the method Throwable.printStackTrace():
> "The first line of output contains the result of the toString() method for this object"
> But NamingException.printStackTrace() doesn't follow this instruction. If the method
> was invoked, NamingException.printStackTrace() will not contain the result of the toString()
method for this exception.
> The test to reproduce the problem:
> import javax.naming.*;
> import java.io.*;
> public class NamingExceptionTest {
>     public static void main(String[] args) throws Exception {
>         NamingException ex = new NamingException("test message");        
>         ByteArrayOutputStream bStream = new ByteArrayOutputStream();
>         PrintStream stream = new PrintStream(bStream);
>         String firstString;
>         String stackTrace;
>         System.setErr(stream);
>         ex.setRemainingName(new CompositeName("element/parent"));
>         ex.setRootCause(new Exception("root cause1"));
>         ex.printStackTrace();
>         stackTrace = bStream.toString();     
>         firstString = ex.toString();
>         if (stackTrace.startsWith(firstString)) {
>             System.out.println("PASSED");
>         } else {
>             System.out.println("FAILED");
>         }
>     }
> }

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message