[
https://issues.apache.org/jira/browse/DERBY-2472?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen reassigned DERBY-2472:
-----------------------------------------
Assignee: Knut Anders Hatlen
Assigning the issue to me since I'm working on it as a background task. If
someone needs this to be resolved quickly, feel free to reassign the issue, and
I'll upload whichever partial patch I have at that point.
Right now what I'm experimenting with is to replace StandardException's
set/getNestedException() and EmbedSQLException's getJavaException() with
initCause/getCause. I'm also using initCause() to link EmbedSQLException's next
exception if no other cause has been specified. An example of the improved
error reporting using this approach:
Running CharacterStreamsTest with the DERBY-827 patch normally gives this error
(stack frames removed):
java.sql.SQLException: Java exception: 'ASSERT FAILED Unexpected exception:
org.apache.derby.shared.common.sanity.AssertFailure'.
With the suggested chaining, this is what JUnit will report:
java.sql.SQLException: Java exception: 'ASSERT FAILED Unexpected exception:
org.apache.derby.shared.common.sanity.AssertFailure'.
Caused by: org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED
Unexpected exception
Caused by: ERROR XCL30: An IOException was thrown when reading a
'java.sql.String' from an InputStream.
Caused by: java.io.EOFException
However, it will take some time to clean up the regression tests.
> Use Throwable.initCause() to improve error reporting
> ----------------------------------------------------
>
> Key: DERBY-2472
> URL: https://issues.apache.org/jira/browse/DERBY-2472
> Project: Derby
> Issue Type: Improvement
> Components: JDBC, Miscellaneous
> Affects Versions: 10.3.0.0
> Reporter: Kristian Waagan
> Assigned To: Knut Anders Hatlen
> Priority: Minor
> Attachments: derby-2472_initial_patch.diff, setStackTrace-v2.diff,
> setStackTrace.diff
>
>
> As Derby has moved to J2SE 1.4, Throwable.initCause() can now be used to
> improve error reporting.
> As stated in the initial commit (that was backed out, see below):
> 'Set Throwable.initCause() in a couple of locations at the JDBC level where
> we setup nested SQLExceptions.
> This means that automatically the stack trace for a database failed to start
> includes the reason
> for the failure, rather than just "see next exception". This is a great help
> when running
> JUnit tests and getting failures to start a database.'
> The initial commit was backed out because it broke numerous tests under JDK
> 1.6, and the author indicated he had no time to investigate.
> The patch caused no failures when running the tests with Java SE 5.0.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.