brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [3/5] brooklyn-server git commit: BROOKLYN-245: improve synchronization in entity
Date Fri, 01 Apr 2016 14:28:15 GMT
BROOKLYN-245: improve synchronization in entity

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c2c1484b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c2c1484b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c2c1484b

Branch: refs/heads/0.9.0
Commit: c2c1484b1f5a1236b1bbc820faca42c426b2456f
Parents: b39c7a0
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Mar 31 20:46:58 2016 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Apr 1 15:27:45 2016 +0100

----------------------------------------------------------------------
 .../org/apache/brooklyn/core/entity/AbstractEntity.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c2c1484b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index 1406855..09834af 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -1484,9 +1484,11 @@ public abstract class AbstractEntity extends AbstractBrooklynObject
implements E
         }
         
         protected SubscriptionContext getSubscriptionContext() {
-            synchronized (AbstractEntity.this) {
-                return getManagementSupport().getSubscriptionContext();
-            }
+            // Rely on synchronization in EntityManagementSupport; synchronizing on AbstractEntity.this
+            // is dangerous because user's entity code might synchronize on that and call
getAttribute.
+            // Given that getSubscriptionContext is called by AttributeMap.update (via emitInternal),
+            // that risks deadlock!
+            return getManagementSupport().getSubscriptionContext();
         }
 
         protected SubscriptionTracker getSubscriptionTracker() {
@@ -1548,7 +1550,7 @@ public abstract class AbstractEntity extends AbstractBrooklynObject
implements E
      * @deprecated since 0.9.0; for internal use only
      */
     @Deprecated
-    protected synchronized SubscriptionTracker getSubscriptionTracker() {
+    protected SubscriptionTracker getSubscriptionTracker() {
         return subscriptions().getSubscriptionTracker();
     }
     


Mime
View raw message