[
https://issues.apache.org/jira/browse/DERBY-6724?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-6724:
--------------------------------------
Attachment: check-null.diff
The NPE happens because InternalTriggerExecutionContext.cleanup() isn't
idempotent. If it is called twice, the second call will fail with NPE because
it accesses fields that were set to null in the first call. In the repro, the
context is first cleaned up after the trigger has executed successfully, and
therefore fails when cleanup() is called again when the prepared statement is
invalidated. With the attached patch [^check-null.diff], cleanup() is made
idempotent, and the repro runs cleanly in my environment.
> NPE if insert statement needs recompilation after having fired a trigger
> ------------------------------------------------------------------------
>
> Key: DERBY-6724
> URL: https://issues.apache.org/jira/browse/DERBY-6724
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.6.1.0, 10.7.1.1,
> 10.8.1.2, 10.9.1.0, 10.10.1.1, 10.11.1.1
> Reporter: Knut Anders Hatlen
> Attachments: Derby6724.java, check-null.diff
>
>
> If an insert statement that has fired a trigger, is needs recompilation
> during execution, it fails with a NullPointerException in
> InternalTriggerExecutionContext.cleanup():
> {noformat}
> java.lang.NullPointerException
> at
> org.apache.derby.impl.sql.execute.InternalTriggerExecutionContext.cleanup(InternalTriggerExecutionContext.java:236)
> at
> org.apache.derby.impl.sql.execute.TriggerEventActivator.cleanup(TriggerEventActivator.java:291)
> at
> org.apache.derby.impl.sql.execute.InsertResultSet.cleanUp(InsertResultSet.java:2199)
> at
> org.apache.derby.impl.sql.conn.GenericStatementContext.cleanupOnError(GenericStatementContext.java:543)
> at
> org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:476)
> at
> org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:349)
> at
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1337)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1709)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1394)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)