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-6373) NPE in Statement.getWarnings()
Date Thu, 17 Oct 2013 14:11:42 GMT

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

Knut Anders Hatlen updated DERBY-6373:

    Attachment: d6373-1a.diff

The attached patch makes SqlWarning.getSQLWarning() follow the warning chain instead of the
exception chain. Since it has already checked that the warning chain is not null, the NPE
is avoided.

The patch also adds a test case which verifies that the NPE is no longer thrown, and that
all the warnings from the batch are received on the client. (The behaviour seems to be slightly
different on embedded. It has only a single warning on the statement after executing the batch.
The client has one warning for each of the statements in the batch that got a warning.)

All regression tests ran cleanly with the patch.

> NPE in Statement.getWarnings()
> ------------------------------
>                 Key: DERBY-6373
>                 URL: https://issues.apache.org/jira/browse/DERBY-6373
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions:
>         Environment: JDK 7
>            Reporter: Glenn McGregor
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: d6373-1a.diff, D6373.java
> After executing a batch in a prepared statement, I call getWarnings() on that statement.
A NPE is thrown.
> 	at org.apache.derby.client.am.SqlWarning.getSQLWarning(SqlWarning.java:117)
> 	at org.apache.derby.client.am.Statement.getWarnings(Statement.java:862)
> ...
> Addtional info:
> In a unit test, which worked for, a batch of 4 deletes were issued.
> They were expected to fail, as there were no matching rows. There was a SQLWarning chain
in the statement, 4 deep, one for each row that failed 
> with text:
> No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table.
> However, each warning had 'nextException_' null. When attempting to chain on the exceptions
when building the warning, a NPE is thrown.
> Perhaps something like changing line 105 of SqlWarning.java to
> if ( nextWarning_ != null && nextException_ != null )
> Of course perhaps there's always supposed to be a corresponding exception.

This message was sent by Atlassian JIRA

View raw message