brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #480: Config self reference fix
Date Fri, 17 Feb 2017 23:40:58 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/480#discussion_r101836841
  
    --- Diff: camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigYamlTest.java
---
    @@ -91,6 +96,62 @@ public void testConfigInConfigBlock() throws Exception {
             assertNull(entity.getMyField()); // field with @SetFromFlag
             assertNull(entity.getMyField2()); // field with @SetFromFlag("myField2Alias"),
set using alias
         }
    +    
    +
    +    @Test
    +    public void testRecursiveConfigFailsGracefully() throws Exception {
    +        doTestRecursiveConfigFailsGracefully(false);
    +    }
    +    
    +    // TODO this test fails because entities aren't available when evaluating immediately
    +    @Test
    +    public void testRecursiveConfigImmediateFailsGracefully() throws Exception {
    +        doTestRecursiveConfigFailsGracefully(true);
    +    }
    +    
    +    protected void doTestRecursiveConfigFailsGracefully(boolean immediate) throws Exception
{
    +        String yaml = Joiner.on("\n").join(
    +                "services:",
    +                "- type: org.apache.brooklyn.core.test.entity.TestEntity",
    +                "  brooklyn.config:",
    +                "    infinite_loop: $brooklyn:config(\"infinite_loop\")");
    +
    +        final Entity app = createStartWaitAndLogApplication(yaml);
    +        TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
    +
    +        Thread t = new Thread(new Runnable() {
    +            @Override
    +            public void run() {
    +                try {
    +                    Time.sleep(Duration.FIVE_SECONDS);
    +                    // error, loop wasn't interrupted or detected
    +                    LOG.warn("Timeout elapsed, destroying items; usage: "+
    +                            ((LocalManagementContext)mgmt()).getGarbageCollector().getUsageString());
    +                    //Entities.destroy(app);
    +                } catch (RuntimeInterruptedException e) {
    +                    // expected on normal execution
    +                    Thread.interrupted();
    --- End diff --
    
    Are you calling this to clear the interrupted status? Why? Do you get an ugly exception
or something if we don't?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message