Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
When using $brooklyn:object with a nested DSL expression that is contained within a list, it does not resolve the nested DSL expression.
This is because it thinks that deferred-evaluation is not necessary. It constructs the object immediately - we end up with a DSL object in the list rather than the resolved value.
The workaround is to include deferred: true inside the brooklyn object.
The problem does not happen if there are any other top-level values in brooklyn.fields that are DSL expressions (it realises then that it must defer the evaluation).
This is demonstrated by adding the following tests to ObjectsYamlTest:
@Test public void testFieldOfTypeListAsDeferredSuppliersExplicitlyDeferred() throws Exception { // Using explicit `deferred: true` Entity testEntity = setupAndCheckTestEntityInBasicYamlWith( " brooklyn.config:", " mystring: myval", " myint: 123", " test.confObject:", " $brooklyn:object:", " type: "+ObjectsYamlTest.class.getName()+"$TestObject", " deferred: true", " object.fields:", " list: ", " - $brooklyn:config(\"mystring\")"); TestObject testObject = (TestObject) testEntity.getConfig(TestEntity.CONF_OBJECT); Assert.assertEquals(testObject.getList(), ImmutableList.of("myval")); } // Fails if don't include `deferred: true` // see {@link #testFieldOfTypeListAsDeferredSuppliersExplicitlyDeferred()} @Test(groups="Broken") public void testFieldOfTypeListAsDeferredSuppliers() throws Exception { // should defer evaluation automatically, and resolve config Entity testEntity = setupAndCheckTestEntityInBasicYamlWith( " brooklyn.config:", " mystring: myval", " myint: 123", " test.confObject:", " $brooklyn:object:", " type: "+ObjectsYamlTest.class.getName()+"$TestObject", " object.fields:", " list: ", " - $brooklyn:config(\"mystring\")"); TestObject testObject = (TestObject) testEntity.getConfig(TestEntity.CONF_OBJECT); Assert.assertEquals(testObject.getList(), ImmutableList.of("myval")); }
Attachments
Issue Links
- links to