This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 245d1d1775af4c65d385d19112049ed4cfb247b3
Author: Alex Heneveld <[email protected]>
AuthorDate: Wed May 24 11:35:40 2023 +0100

    better checks for errors when creating a spec via coercion
---
 .../java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
index e124b80bcb..29bd8f3b50 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/mgmt/EntityManagementUtils.java
@@ -207,7 +207,12 @@ public class EntityManagementUtils {
                 try {
                     Object yo = Iterables.getOnlyElement(Yamls.parseAll(yaml));
                     // coercion does this at: 
org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.BrooklynDslCommon.registerSpecCoercionAdapter
+                    // but is too forgiving -- will coerce an empty map; so we 
do an extra check
                     spec = TypeCoercions.tryCoerce(yo, 
EntitySpec.class).orNull();
+                    if (spec.getType()==null && 
spec.getImplementation()==null) {
+                        if (log.isTraceEnabled()) log.trace("Failed converting 
entity spec YAML as YAML, transformer error will throw, but also created a 
bogus empty spec: "+spec+", from "+yo);
+                        spec = null;
+                    }
                 } catch (Exception e2) {
                     log.debug("Failed converting entity spec YAML as YAML, 
transformer error will throw, but also encountered: "+e2);
                 }

Reply via email to