harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2638) [luni][jndi] javax.naming.NamingException.printStackTrace() output should contain the output of NamingException.toString()
Date Tue, 12 Dec 2006 12:24:21 GMT
[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 NamingException.setRootCause(Throwable)
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

        

Mime
View raw message