You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2008/01/23 14:22:08 UTC
svn commit: r614530 -
/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java
Author: kahatlen
Date: Wed Jan 23 05:22:06 2008
New Revision: 614530
URL: http://svn.apache.org/viewvc?rev=614530&view=rev
Log:
DERBY-3260: NullPointerException caused by race condition in GenericActivationHolder
Merged fix from trunk (svn merge -c 613815 ../trunk)
Modified:
db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java
Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java?rev=614530&r1=614529&r2=614530&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java Wed Jan 23 05:22:06 2008
@@ -255,9 +255,20 @@
if (gc != ps.getActivationClass())
{
+ GeneratedClass newGC;
+
// ensure the statement is valid by rePreparing it.
- ps.rePrepare(getLanguageConnectionContext());
-
+ // DERBY-3260: If someone else reprepares the statement at the
+ // same time as we do, there's a window between the calls to
+ // rePrepare() and getActivationClass() when the activation
+ // class can be set to null, leading to NullPointerException
+ // being thrown later. Therefore, synchronize on ps to close
+ // the window.
+ synchronized (ps) {
+ ps.rePrepare(getLanguageConnectionContext());
+ newGC = ps.getActivationClass();
+ }
+
/*
** If we get here, it means the PreparedStatement has been
** recompiled. Get a new Activation and check whether the
@@ -265,8 +276,6 @@
** from the old Activation to the new one, and make that the
** current Activation. If not, throw an exception.
*/
- GeneratedClass newGC = ps.getActivationClass();
-
BaseActivation newAC = (BaseActivation) newGC.newInstance(lcc);
DataTypeDescriptor[] newParamTypes = ps.getParameterTypes();