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, 04 Apr 2011 11:19:05 GMT

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

Knut Anders Hatlen commented on DERBY-4443:

It looks like the rollback exception is stripped off by this piece of code in StandardException.unexpectedUserException():

		// Look for simple wrappers for 3.0.1 - will be cleaned up in main
		if (ferry != null) {
			if (ferry.isSimpleWrapper()) {
				Throwable wrapped = ((SQLException)ferry).getCause();
				if (wrapped instanceof StandardException)
					return (StandardException) wrapped;

This happens when the SQLException needs to be re-thrown as a StandardException, and the error
handler finds that it's simpler to remove the top-level SQLException than it is to wrap it
in yet another exception. Normally, an SQLException that wraps a StandardException doesn't
provide any extra information, so removing it doesn't harm. But in our case the top-level
exception carries extra information (the next exception), and it's not really a simple wrapper
anymore. Perhaps we need to override setNextException() in EmbedSQLException and clear the
simpleWrapper flag if it's called. The comments in the StandardException class give the impression
that this "simple wrapper" code was a temporary hack that was supposed to be reworked, but
they don't give any details on how.

> 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-5.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