Repository: brooklyn-server Updated Branches: refs/heads/master 7dd9d1ba2 -> d9e8cf490
Fix conditional entity null check missed in PR Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/d9e8cf49 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/d9e8cf49 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/d9e8cf49 Branch: refs/heads/master Commit: d9e8cf4907d21a3ab1daa472ed069e3998d0b0e8 Parents: 7dd9d1b Author: Andrew Donald Kennedy <[email protected]> Authored: Wed Jul 27 07:38:37 2016 +0100 Committer: Andrew Donald Kennedy <[email protected]> Committed: Wed Jul 27 07:38:37 2016 +0100 ---------------------------------------------------------------------- .../apache/brooklyn/entity/stock/ConditionalEntityImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d9e8cf49/core/src/main/java/org/apache/brooklyn/entity/stock/ConditionalEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/entity/stock/ConditionalEntityImpl.java b/core/src/main/java/org/apache/brooklyn/entity/stock/ConditionalEntityImpl.java index c9becbe..f9949b9 100644 --- a/core/src/main/java/org/apache/brooklyn/entity/stock/ConditionalEntityImpl.java +++ b/core/src/main/java/org/apache/brooklyn/entity/stock/ConditionalEntityImpl.java @@ -20,8 +20,6 @@ package org.apache.brooklyn.entity.stock; import java.util.Collection; -import com.google.common.base.Preconditions; - import org.apache.brooklyn.api.entity.Entity; import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.location.Location; @@ -31,9 +29,11 @@ public class ConditionalEntityImpl extends BasicStartableImpl implements Conditi @Override public void start(Collection<? extends Location> locations) { Entity child = sensors().get(CONDITIONAL_ENTITY); + EntitySpec<?> spec = config().get(CONDITIONAL_ENTITY_SPEC); Boolean create = config().get(CREATE_CONDITIONAL_ENTITY); - if (Boolean.TRUE.equals(create) && child == null) { - EntitySpec<?> spec = Preconditions.checkNotNull(config().get(CONDITIONAL_ENTITY_SPEC)); + + // Child not yet created; Entity spec is present; Create flag is true if set + if (child == null && spec != null && (create == null || Boolean.TRUE.equals(create))) { Entity created = addChild(EntitySpec.create(spec)); sensors().set(CONDITIONAL_ENTITY, created); }
