db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r882538 - in /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor: ModuleInstance.java TopService.java
Date Fri, 20 Nov 2009 12:52:29 GMT
Author: kmarsden
Date: Fri Nov 20 12:52:29 2009
New Revision: 882538

URL: http://svn.apache.org/viewvc?rev=882538&view=rev
Log:
DERBY-2074 NullPointerException when two threads load sort factory concurrently
Contributed by Knut Anders Hatlen
merge 789103 code fix from 10.5 branch


Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/TopService.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java?rev=882538&r1=882537&r2=882538&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/ModuleInstance.java
Fri Nov 20 12:52:29 2009
@@ -56,6 +56,9 @@
 	*/
 	protected Object	service;
 
+    /** Flag that tells whether booting of the module has completed. */
+    private boolean booted;
+
 	/*
 	** Constructor
 	*/
@@ -111,4 +114,20 @@
 	protected Object getInstance() {
 		return instance;
 	}
+
+    /**
+     * Set a flag that indicates that booting of the module has completed.
+     */
+    synchronized void setBooted() {
+        booted = true;
+    }
+
+    /**
+     * Check whether booting of the module has completed.
+     * @return {@code true} if the module has been booted, or {@code false}
+     * otherwise
+     */
+    synchronized boolean isBooted() {
+        return booted;
+    }
 }

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/TopService.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/TopService.java?rev=882538&r1=882537&r2=882538&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/TopService.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/TopService.java
Fri Nov 20 12:52:29 2009
@@ -255,6 +255,16 @@
 			for (int i = 0; i < moduleInstances.size(); i++) {
 				ModuleInstance module = (ModuleInstance) moduleInstances.elementAt(i);
 
+                // DERBY-2074: The module has not been properly booted, so we
+                // cannot yet determine whether or not this is a module we can
+                // use. Assume that we cannot use it and continue looking. We
+                // may end up booting the module twice if the assumption
+                // doesn't hold, but we'll detect and resolve that later when
+                // we call addToProtocol().
+                if (!module.isBooted()) {
+                    continue;
+                }
+
 				if (!module.isTypeAndName((PersistentService) null, key.getFactoryInterface(), key.getIdentifier()))
 					continue;
 
@@ -294,6 +304,8 @@
 			throw se;
 		}
 
+        module.setBooted();
+
 		synchronized (this) {
 
 



Mime
View raw message