Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 40F69200AF7 for ; Mon, 30 May 2016 16:28:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3F938160969; Mon, 30 May 2016 14:28:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 882B9160A19 for ; Mon, 30 May 2016 16:28:05 +0200 (CEST) Received: (qmail 69944 invoked by uid 500); 30 May 2016 14:28:04 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 69901 invoked by uid 99); 30 May 2016 14:28:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 May 2016 14:28:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 80FBFDFBE4; Mon, 30 May 2016 14:28:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: svet@apache.org To: commits@brooklyn.apache.org Date: Mon, 30 May 2016 14:28:04 -0000 Message-Id: <803af5cb0ed745529a67e3570289bdd2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] brooklyn-server git commit: BROOKLYN-284: fix deadlock in entity initialisation archived-at: Mon, 30 May 2016 14:28:06 -0000 Repository: brooklyn-server Updated Branches: refs/heads/master 5626d1d91 -> 0b7071cff BROOKLYN-284: fix deadlock in entity initialisation Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/8339fc60 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/8339fc60 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/8339fc60 Branch: refs/heads/master Commit: 8339fc6061cff7f654970be5ecefc56d19827197 Parents: 4162971 Author: Aled Sage Authored: Fri May 27 21:29:13 2016 +0100 Committer: Aled Sage Committed: Sat May 28 14:19:27 2016 +0100 ---------------------------------------------------------------------- .../brooklyn/core/entity/AbstractEntity.java | 5 ++++- .../brooklyn/core/entity/EntityTypeTest.java | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8339fc60/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 bde505c..62a4bf8 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 @@ -1580,7 +1580,10 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E } @Override - public synchronized ExecutionContext getExecutionContext() { + public ExecutionContext getExecutionContext() { + // NB May 2016 - removed synch keyword above due to deadlock (see https://issues.apache.org/jira/browse/BROOKLYN-284). + // As with getManagementContext(), it also synchs in ManagementSupport.getExecutionContext(); + // no apparent reason why it was here also. return getManagementSupport().getExecutionContext(); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8339fc60/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java index 641f97b2..c6e3936 100644 --- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java @@ -264,7 +264,7 @@ public class EntityTypeTest extends BrooklynAppUnitTestSupport { } // Previously EntityDynamicType's constructor when passed `entity` during the entity's construction (!) - // would pass this to EntityDynamicType.findEffectors, which would do log.warn in some cirumstances, + // would pass this to EntityDynamicType.findEffectors, which would do log.warn in some circumstances, // with entity.toString as part of the log message. But if the toString called getConfig() this would // fail because we were still in the middle of constructing the entity.entityType! @Test @@ -272,7 +272,21 @@ public class EntityTypeTest extends BrooklynAppUnitTestSupport { entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).impl(EntityWithToStringAccessingConfig.class)); entity.toString(); } - + + /** + * Previously this deadlocked when calling toString() during entity initialisation (but only if the config key + * had a value - this would trigger a call by EntityConfigMap.getConfig() to getExecutionContext). + * + * See https://issues.apache.org/jira/browse/BROOKLYN-284 + */ + @Test + public void testEntityDoesNotCallToStringDuringConstruction() throws Exception { + entity = app.createAndManageChild(EntitySpec.create(TestEntity.class) + .impl(EntityWithToStringAccessingConfig.class) + .configure(TestEntity.CONF_NAME, "myval")); + entity.toString(); + } + public static class EntityWithToStringAccessingConfig extends TestEntityImpl { // to cause warning to be logged: non-static constant