directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kiran Ayyagari (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DIRSERVER-1299) Add causes when rethrowing caught exceptions (e.g. in org.apache.directory.server.integ.state.NonExistentState)
Date Tue, 26 Jan 2010 11:48:34 GMT

    [ https://issues.apache.org/jira/browse/DIRSERVER-1299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12804988#action_12804988
] 

Kiran Ayyagari commented on DIRSERVER-1299:
-------------------------------------------

Aleksander,

     There is a new test framework which no longer depends on these XXXStates and
     simplifies writing tests and allows us to define a

       i. DirectoryService at Suite,Class and Method levels 
       ii. LdapServer at Suite and Class levels
       iii. KdcServer at Suite and Class levels

       with support for inheriting a DirectoryService/LdapServer/KdcServer in the order
  
       Method -> Class -> Suite

       and also support for injecting and reverting LDIFs at Method, Class and Suite levels

     You can give this test framework a try and let us know. 


> 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
>             Fix For: 2.0.0-RC1
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message