[
https://issues.apache.org/jira/browse/DERBY-4443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012859#comment-13012859
]
Knut Anders Hatlen commented on DERBY-4443:
-------------------------------------------
Thanks for making these changes. I didn't see any response to my question about
the order of the exception chain. If I print the exception thrown by
rollBackAndThrowSQLException(), I see this:
java.sql.SQLException: The exception 'java.sql.SQLException: error in roll
back' was thrown while evaluating an expression.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:98)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:142)
at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:278)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:403)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:348)
at
org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2290)
at
org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
at
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1334)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
at
org.apache.derby.impl.jdbc.EmbedCallableStatement.executeStatement(EmbedCallableStatement.java:117)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:308)
at
org.apache.derbyTesting.functionTests.tests.tools.RollBackWrappingWhenFailOnImportTest.realTestRollBackWhenImportOnNonexistentFile(RollBackWrappingWhenFailOnImportTest.java:152)
at
org.apache.derbyTesting.functionTests.tests.tools.RollBackWrappingWhenFailOnImportTest.testRollBackWhenFailOnImportTable(RollBackWrappingWhenFailOnImportTest.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at
org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:112)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.extensions.TestSetup.run(TestSetup.java:27)
at
org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:180)
at junit.textui.TestRunner.main(TestRunner.java:138)
Caused by: java.sql.SQLException: The exception 'java.sql.SQLException: error
in roll back' was thrown while evaluating an expression.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:122)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71)
... 35 more
Caused by: java.sql.SQLException: error in roll back
at
org.apache.derbyTesting.functionTests.tests.tools.RollBackWrappingWhenFailOnImportTest$MockInternalDriver$MockConnectionFailWhenRollBack.rollback(RollBackWrappingWhenFailOnImportTest.java:59)
at
org.apache.derby.catalog.SystemProcedures.rollBackAndThrowSQLException(SystemProcedures.java:1479)
at
org.apache.derby.catalog.SystemProcedures.SYSCS_IMPORT_TABLE(SystemProcedures.java:1466)
at
org.apache.derby.exe.aceaa980c4x012fx0589x77eaxffffbc38504a0.g0(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.derby.impl.services.reflect.ReflectMethod.invoke(ReflectMethod.java:46)
at
org.apache.derby.impl.sql.execute.CallStatementResultSet.open(CallStatementResultSet.java:75)
at
org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
at
org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
at
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1242)
... 28 more
For a naive user, this looks like a problem in rollback(), like it did before
the fix, and there's no trace of the original "table not found" exception
without doing some digging in the logs or traversing the getNextException()
chain. Any thoughts on whether this is the exception we should report as the
primary exception?
> 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-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