[ 
https://issues.apache.org/jira/browse/DERBY-4443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012073#comment-13012073
 ] 

Knut Anders Hatlen commented on DERBY-4443:
-------------------------------------------

I agree that the approach looks fine. Some minor comments:

- When calling printStackTrace() on the thrown exception, only the rollback 
exception is thrown. To see the real problem, you either need to call 
getNextException() or look in derby.log. Would it make sense to change the 
order here? That is, in rollBackAndThrowSQLException(), change

            e.setNextException(se);
            throw e;

to

            se.setNextException(e);
            throw se;
?

- There are three calls to printStackTrace() in the test code. It would 
probably be better to throw the exceptions so that JUnit can report them 
properly. If the exceptions are expected, it would be better to ignore them 
(with a comment saying why they should be ignored) or to have some asserts to 
verify that they are the exceptions we expect.

> Wrap rollback in exception handlers in try-catch
> ------------------------------------------------
>
>                 Key: DERBY-4443
>                 URL: https://issues.apache.org/jira/browse/DERBY-4443
>             Project: Derby
>          Issue Type: Bug
>          Components: Demos/Scripts, Documentation, Eclipse Plug-in, JDBC, 
> Network Client, Network Server, Replication, Services, SQL, Test, Tools
>    Affects Versions: 10.5.3.0
>            Reporter: Aaron Digulla
>            Assignee: Houx Zhang
>              Labels: derby_triage10_8
>         Attachments: DERBY-4443-1.patch, DERBY-4443-2.patch, 
> DERBY-4443-3.patch, DERBY-4443-4.patch, DERBY-4443-4.png, DERBY-4443.patch
>
>
> Avoid this pattern everywhere:
>               }catch(SQLException se){
>                       //issue a rollback on any errors
>                       conn.rollback();
>                       throw  se;
>               }
> because an error in rollback will shadow the original exception.

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

Reply via email to