db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1051271 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
Date Mon, 20 Dec 2010 20:12:58 GMT
Author: kristwaa
Date: Mon Dec 20 20:12:58 2010
New Revision: 1051271

URL: http://svn.apache.org/viewvc?rev=1051271&view=rev
Log:
DERBY-4947: Missing/broken synchronization in BasicDependencyManager.getDependents() 

Fixed unsynchronized access to a shared structure. The references to the
elements in the list are now copied to a new list.

Patch file: derby-4947-1a-sync_fix.diff


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java?rev=1051271&r1=1051270&r2=1051271&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
Mon Dec 20 20:12:58 2010
@@ -318,8 +318,7 @@ public class BasicDependencyManager impl
 	{
 		List list = getDependents(p);
 
-		if (list == null)
-		{
+        if (list.isEmpty()) {
 			return;
 		}
 
@@ -976,7 +975,8 @@ public class BasicDependencyManager impl
 	 * that the dependent removal is being dealt with elsewhere.
 	 * Won't assume that the dependent only appears once in the list.
 	 */
-	protected void clearProviderDependency(UUID p, Dependency d) {
+    //@GuardedBy("this")
+    private void clearProviderDependency(UUID p, Dependency d) {
 		List deps = (List) providers.get(p);
 
 		if (deps == null)
@@ -1108,14 +1108,17 @@ public class BasicDependencyManager impl
      * invalid ones). Includes all dependency types.
      *
      * @param p the provider
-     * @return {@code null} or a list of dependents (possibly empty).
+     * @return A list of dependents (possibly empty).
      * @throws StandardException if something goes wrong
 	 */
 	private List getDependents (Provider p) 
 			throws StandardException {
-        List deps;
+        List deps = new ArrayList();
         synchronized (this) {
-            deps = (List) providers.get(p.getObjectID());
+            List memDeps = (List) providers.get(p.getObjectID());
+            if (memDeps != null) {
+                deps.addAll(memDeps);
+            }
         }
 
         // If the provider is persistent, then we have to add providers for
@@ -1127,16 +1130,7 @@ public class BasicDependencyManager impl
 															),
 							p
 													);
-            if (deps == null) {
-                deps = storedList;
-            } else {
-                // We can't modify the list we got from 'providers', create a
-                // new one to merge the two lists.
-                List merged = new ArrayList(deps.size() + storedList.size());
-                merged.addAll(deps);
-                merged.addAll(storedList);
-                deps = merged;
-            }
+            deps.addAll(storedList);
         }
         return deps;
 	}



Mime
View raw message