directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (DIRSERVER-1299) Add causes when rethrowing caught exceptions (e.g. in org.apache.directory.server.integ.state.NonExistentState)
Date Thu, 09 Jun 2011 18:59:00 GMT

     [ https://issues.apache.org/jira/browse/DIRSERVER-1299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Emmanuel Lecharny resolved DIRSERVER-1299.
------------------------------------------

    Resolution: Fixed

Fixed with : http://svn.apache.org/viewvc?rev=1134019&view=rev


> Add causes when rethrowing caught exceptions (e.g. in org.apache.directory.server.integ.state.NonExistentState)
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRSERVER-1299
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1299
>             Project: Directory ApacheDS
>          Issue Type: Improvement
>            Reporter: Aleksander Adamowski
>            Priority: Minor
>             Fix For: 2.0.0-M1
>
>
> In general, in many places in the code exceptions are rethrown only with the message
from the original exception. In tha case of some exceptions, there is no message and only
the original exception with its stack trace could help track down the problem.
> I've been bitten by this when using org.apache.directory.server.integ.state.NonExistentState:
> javax.naming.NamingException
> 	at org.apache.directory.server.integ.state.NonExistentState.create(NonExistentState.java:86)
> 	at org.apache.directory.server.integ.state.NonExistentState.test(NonExistentState.java:180)
> 	at org.apache.directory.server.integ.state.TestServerContext.test(TestServerContext.java:187)
> 	at org.apache.directory.server.integ.SiRunner.invokeTestMethod(SiRunner.java:103)
> 	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
> 	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
> 	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
> 	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> 	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
> 	at org.apache.directory.server.integ.SiRunner.run(SiRunner.java:77)
> 	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> 	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
> 	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
> 	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> As can be seen in NonExistentState.java:86 the exception that is thrown is not initialized
with its cause exception (I suspect that it was a NullPointerException):
> catch ( Exception e )
>         {
>             throw new NamingException( e.getMessage() );
>         }
> I believe this should be written like this:
> catch ( Exception e )
>         {
>             NamingException rethrownEx = new NamingException( e.getMessage() );
>             rethrownEx.setRootCause(e);
>             throw rethrownEx ;
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message