brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #390: BROOKLYN-356: fix race in transformer by ...
Date Tue, 01 Nov 2016 13:52:24 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/390#discussion_r85929615
  
    --- Diff: core/src/test/java/org/apache/brooklyn/util/core/task/ValueResolverTest.java
---
    @@ -69,46 +59,65 @@ public void testTimeoutBig() {
             Assert.assertEquals(result.get(), "foo");
         }
     
    -    public void testNoExecutionContextOnCompleted() {
    +    public void testCompletedTaskReturnsResultImmediately() {
    +        // Call ValueResolver.getMaybe() from this thread, which has no execution context.
    +        // However, the task has already been submitted and we have waited for it to
complete.
    +        // Therefore the ValueResolver can simply check for task.isDone() and return
its result immediately.
             Task<String> t = newSleepTask(Duration.ZERO, "foo");
             app.getExecutionContext().submit(t).getUnchecked();
             Maybe<String> result = Tasks.resolving(t).as(String.class).timeout(Duration.ZERO).getMaybe();
             Assert.assertEquals(result.get(), "foo");
         }
     
    -    public static Throwable assertThrowsOnMaybe(ValueResolver<?> result) {
    -        try {
    -            result = result.clone();
    -            result.getMaybe();
    -            Assert.fail("should have thrown");
    -            return null;
    -        } catch (Exception e) { return e; }
    +    public void testUnsubmittedTaskWhenNoExecutionContextFails() {
    +        // ValueResolver.getMaybe() is called with no execution context. Therefore it
will not execute the task.
    +        Task<String> t = newSleepTask(Duration.ZERO, "foo");
    +        Maybe<String> result = Tasks.resolving(t).as(String.class).timeout(Duration.ZERO).getMaybe();
    +        
    +        Assert.assertTrue(result.isAbsent(), "result="+result);
    +        Exception exception = ((Maybe.Absent<?>)result).getException();
    --- End diff --
    
    Can use `Maybe.getException(result)`.


---
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