db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4443) Wrap rollback in exception handlers in try-catch
Date Sun, 20 Mar 2011 15:28:29 GMT

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

Bryan Pendleton commented on DERBY-4443:

I modified the setUp() method of your patch so that it looks like this:

    protected void setUp()
        throws Exception
        System.out.println("setUp is called!");
        MockInternalDriver dvr = new MockInternalDriver();
        dvr.boot(false, null);

and now the test gets considerably further. It gets to the point where
it tries to make a new connection, and then fails.

I think that your connect() method in your MockInternalDriver
must do more than just return an empty MockConnection().

I think that you have to call super.connect(url, info), and then
take the real connection that the superclass creates and wrap
that connection in your MockConnection.

So your connect() method should probably look something like:

    return new MockConnection(super.connect(url, info));

and your MockConnection class will need to have a private
internal Connection object that it delegates to.

Does that make sense? Hopefully this helps you get further
in building your test case.

> 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
>              Labels: derby_triage10_8
>         Attachments: DERBY-4443-1.patch, 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