incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r995023 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/RootResourceProviderEntry.java
Date Wed, 08 Sep 2010 12:34:18 GMT
Author: cziegeler
Date: Wed Sep  8 12:34:17 2010
New Revision: 995023

URL: http://svn.apache.org/viewvc?rev=995023&view=rev
Log:
SLING-1736 : Potential Deadlock while registering/unregistering ResourceProvider

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/RootResourceProviderEntry.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/RootResourceProviderEntry.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/RootResourceProviderEntry.java?rev=995023&r1=995022&r2=995023&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/RootResourceProviderEntry.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/RootResourceProviderEntry.java
Wed Sep  8 12:34:17 2010
@@ -57,27 +57,26 @@ public class RootResourceProviderEntry e
         if (roots != null && roots.length > 0) {
             final EventAdmin localEA = (EventAdmin) ( eventAdminTracker != null ? eventAdminTracker.getService()
: null);
 
-            // synchronized insertion of new resource providers into
-            // the tree to not inadvertently loose an entry
-            synchronized (this) {
-
-                for (String root : roots) {
-                    // cut off trailing slash
-                    if (root.endsWith("/") && root.length() > 1) {
-                        root = root.substring(0, root.length() - 1);
-                    }
+            for (String root : roots) {
+                // cut off trailing slash
+                if (root.endsWith("/") && root.length() > 1) {
+                    root = root.substring(0, root.length() - 1);
+                }
+
+                // synchronized insertion of new resource providers into
+                // the tree to not inadvertently loose an entry
+                synchronized (this) {
 
                     this.addResourceProvider(root,
                         provider, OsgiUtil.getComparableForServiceRanking(props));
-
-                    logger.debug("bindResourceProvider: {}={} ({})",
-                        new Object[] { root, provider, serviceName });
-                    if ( localEA != null ) {
-                        final Dictionary<String, Object> eventProps = new Hashtable<String,
Object>();
-                        eventProps.put(SlingConstants.PROPERTY_PATH, root);
-                        localEA.postEvent(new Event(SlingConstants.TOPIC_RESOURCE_PROVIDER_ADDED,
-                                eventProps));
-                    }
+                }
+                logger.debug("bindResourceProvider: {}={} ({})",
+                    new Object[] { root, provider, serviceName });
+                if ( localEA != null ) {
+                    final Dictionary<String, Object> eventProps = new Hashtable<String,
Object>();
+                    eventProps.put(SlingConstants.PROPERTY_PATH, root);
+                    localEA.postEvent(new Event(SlingConstants.TOPIC_RESOURCE_PROVIDER_ADDED,
+                            eventProps));
                 }
             }
         }
@@ -98,28 +97,27 @@ public class RootResourceProviderEntry e
 
             final EventAdmin localEA = (EventAdmin) ( eventAdminTracker != null ? eventAdminTracker.getService()
: null);
 
-            // synchronized insertion of new resource providers into
-            // the tree to not inadvertently loose an entry
-            synchronized (this) {
-                for (String root : roots) {
-                    // cut off trailing slash
-                    if (root.endsWith("/") && root.length() > 1) {
-                        root = root.substring(0, root.length() - 1);
-                    }
+            for (String root : roots) {
+                // cut off trailing slash
+                if (root.endsWith("/") && root.length() > 1) {
+                    root = root.substring(0, root.length() - 1);
+                }
 
+                // synchronized insertion of new resource providers into
+                // the tree to not inadvertently loose an entry
+                synchronized (this) {
                     // TODO: Do not remove this path, if another resource
                     // owns it. This may be the case if adding the provider
                     // yielded an ResourceProviderEntryException
                     this.removeResourceProvider(root, provider, OsgiUtil.getComparableForServiceRanking(props));
-
-                    logger.debug("unbindResourceProvider: root={} ({})", root,
-                        serviceName);
-                    if ( localEA != null ) {
-                        final Dictionary<String, Object> eventProps = new Hashtable<String,
Object>();
-                        eventProps.put(SlingConstants.PROPERTY_PATH, root);
-                        localEA.postEvent(new Event(SlingConstants.TOPIC_RESOURCE_PROVIDER_REMOVED,
-                                eventProps));
-                    }
+                }
+                logger.debug("unbindResourceProvider: root={} ({})", root,
+                    serviceName);
+                if ( localEA != null ) {
+                    final Dictionary<String, Object> eventProps = new Hashtable<String,
Object>();
+                    eventProps.put(SlingConstants.PROPERTY_PATH, root);
+                    localEA.postEvent(new Event(SlingConstants.TOPIC_RESOURCE_PROVIDER_REMOVED,
+                            eventProps));
                 }
             }
         }



Mime
View raw message