Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/480#discussion_r103500687
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionContext.java
 ---
    @@ -96,7 +98,50 @@ public ExecutionManager getExecutionManager() {
         /** returns tasks started by this context (or tasks which have all the 
tags on this object) */
         @Override
         public Set<Task<?>> getTasks() { return 
executionManager.getTasksWithAllTags(tags); }
    -     
    +
    +    /** performs execution without spawning a new task thread, though it 
does temporarily set a fake task for the purpose of getting context;
    +     * currently supports suppliers or callables  */
    +    @SuppressWarnings("unchecked")
    +    @Override
    +    public <T> Maybe<T> getImmediately(Object callableOrSupplier) {
    +        BasicTask<?> fakeTaskForContext;
    +        if (callableOrSupplier instanceof BasicTask) {
    +            fakeTaskForContext = (BasicTask<?>)callableOrSupplier;
    +            if (fakeTaskForContext.isQueuedOrSubmitted()) {
    +                if (fakeTaskForContext.isDone()) {
    +                    return Maybe.of((T)fakeTaskForContext.getUnchecked());
    +                } else {
    +                    throw new ImmediateUnsupportedException("Task is in 
progress and incomplete: "+fakeTaskForContext);
    +                }
    +            }
    +            callableOrSupplier = fakeTaskForContext.getJob();
    --- End diff --
    
    as above


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to