You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/11/23 11:39:00 UTC

[jira] [Commented] (BROOKLYN-565) brooklyn:object with nested DSL inside list is not resolved

    [ https://issues.apache.org/jira/browse/BROOKLYN-565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16264219#comment-16264219 ] 

ASF GitHub Bot commented on BROOKLYN-565:
-----------------------------------------

GitHub user aledsage opened a pull request:

    https://github.com/apache/brooklyn-server/pull/904

    BROOKLYN-565: fix Brooklyn:object with nested dsl

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server BROOKLYN-565

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/904.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #904
    
----
commit 397a83253c13a50f63eacdad1a2c91a98f59fc23
Author: Aled Sage <al...@gmail.com>
Date:   2017-11-23T11:37:26Z

    BROOKLYN-565: fix Brooklyn:object with nested dsl

----


> brooklyn:object with nested DSL inside list is not resolved
> -----------------------------------------------------------
>
>                 Key: BROOKLYN-565
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-565
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Aled Sage
>
> 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}}:
> {noformat}
>     @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"));
>     }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)