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] Updated: (DERBY-2472) Use Throwable.initCause() to improve error reporting
Date Thu, 31 May 2007 12:39:16 GMT

     [ https://issues.apache.org/jira/browse/DERBY-2472?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Knut Anders Hatlen updated DERBY-2472:
--------------------------------------

    Attachment: setnext.stat
                setnext.diff

I went through all the calls to SQLException.setNextException() in the engine code to see
if there were more problems with the chaining. Most of them seemed OK, as they for instance
cleaned up after an error and put the subsequent exceptions into the next chain. In those
cases initCause() is not necessary because the subsequent errors are not causing the first
error, and the first error is what is thrown to the caller.

The problems I found, were:

  1) EmbedStatement.executeBatch() catches SQLException and re-throws it as BatchUpdateException.
It only links it to the original exception with setNextException(), but should also have used
initCause().

  2) EmbedResultSet.closeOnTransactionError() tries to close the ResultSet, and if close()
fails, it throws the exception from close() with a next pointer to the original exception.
It should always throw the original exception, and instead have a next pointer to the exception
thrown from close(). No need for initCause() since the exceptions don't necessarily cause
each other, and you'll always get the original (and most interesting) exception.

  3) ImportReadData.realOpenFile() sets the cause of the SQLException by manually creating
an SQLException with the same message as the original Java exception and calling setNextException().
Instead, it should use factory methods which performs the correct chaining.

The attached patch fixes these issues. Derbyall and suites.All ran cleanly.

> 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
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: derby-2472_initial_patch.diff, embedsqlexception.diff, embedsqlexception.stat,
initCause.diff, initCause.stat, initCause2.diff, initCause2.stat, seenext.diff, seenext.stat,
setnext.diff, setnext.stat, setStackTrace-v2.diff, setStackTrace.diff, standardexception.diff,
standardexception.stat
>
>
> 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.


Mime
View raw message