brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Tasks cancellation
Date Wed, 20 Jan 2016 16:54:43 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1160#discussion_r50282211
  
    --- Diff: brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
---
    @@ -665,9 +728,27 @@ protected void internalBeforeStart(Map<?,?> flags, Task<?>
task) {
                 PerThreadCurrentTaskHolder.perThreadCurrentTask.set(task);
                 ((TaskInternal<?>)task).setStartTimeUtc(System.currentTimeMillis());
             }
    -        ExecutionUtils.invoke(flags.get("newTaskStartCallback"), task);
    +        invokeCallback(flags.get("newTaskStartCallback"), task);
         }
     
    +    @SuppressWarnings({ "unchecked", "rawtypes" })
    +    // not ideal, such loose typing on the callback -- should prefer Function<Task,Object>
    +    // but at least it's package-private
    +    static Object invokeCallback(Object callable, Task<?> task) {
    +        if (callable instanceof Closure) return ((Closure<?>)callable).call(task);
    +        if (callable instanceof Callable) {
    +            try {
    +                return ((Callable<?>)callable).call();
    +            } catch (Throwable t) {
    +                throw Throwables.propagate(t);
    --- End diff --
    
    Should use `Exceptions.propagate(t)`, so we properly handle `InterruptedException`.


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