db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1062096 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
Date Sat, 22 Jan 2011 04:04:17 GMT
Author: kmarsden
Date: Sat Jan 22 04:04:17 2011
New Revision: 1062096

URL: http://svn.apache.org/viewvc?rev=1062096&view=rev
Log:
DERBY-4973 NullPointerException in updatelocks.sql encryption tests on IBM 1.6

Change Xact.getContextId() to just read xc value once to avoid possible NPE with lock table
query.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java?rev=1062096&r1=1062095&r2=1062096&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java Sat Jan
22 04:04:17 2011
@@ -624,14 +624,17 @@ public class Xact extends RawTransaction
 		return myId;
 	}
 
-	/**
-		Get my transaction context Id
-	*/
-	public final String getContextId() 
-	{
-		return (xc == null) ? null : xc.getIdName();
-	}
-
+    /**
+     * Get my transaction context Id
+     */
+    public final String getContextId() {
+        //DERBY-4973. Make a copy of xc so we are working on a stable 
+        // copy, especially for the lock table VTI. If we don't, there may
+        // be a chance for a NullPointerException if close() is called 
+        //by another thread after the check but before the dereference.
+        XactContext tempxc = xc;
+        return (tempxc == null) ? null : tempxc.getIdName();
+    }
 
 	/**
 		Get the current default locking policy for all operations within this



Mime
View raw message