db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-4443) Wrap rollback in exception handlers in try-catch
Date Mon, 28 Mar 2011 14:24:07 GMT

    [ 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(),

            throw 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:
>            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

View raw message