Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/83#discussion_r15468119
--- Diff: core/src/main/java/brooklyn/util/task/BasicExecutionManager.java
---
@@ -300,47 +300,64 @@ public long getNumInMemoryTasks() {
task.submitTimeUtc = System.currentTimeMillis();
tasksById.put(task.getId(), task);
if (!task.isDone()) {
- task.result = delayedRunner.schedule(new
Callable<Object>() { @SuppressWarnings("rawtypes")
- public Object call() {
- if (task.startTimeUtc==-1) task.startTimeUtc =
System.currentTimeMillis();
- try {
- beforeStart(flags, task);
- final TaskInternal<?> taskScheduled =
(TaskInternal<?>) task.newTask();
- taskScheduled.setSubmittedByTask(task);
- final Callable<?> oldJob =
taskScheduled.getJob();
- taskScheduled.setJob(new Callable() {
public Object call() {
- task.recentRun = taskScheduled;
- synchronized (task) {
- task.notifyAll();
- }
- Object result;
- try {
- result = oldJob.call();
- } catch (Exception e) {
- log.warn("Error executing
"+oldJob+" (scheduled job of "+task+" - "+task.getDescription()+"); cancelling
scheduled execution", e);
- throw Exceptions.propagate(e);
- }
- task.runCount++;
- if (task.period!=null &&
!task.isCancelled()) {
- task.delay = task.period;
- submitNewScheduledTask(flags, task);
- }
- return result;
- }});
- task.nextRun = taskScheduled;
- BasicExecutionContext ec =
BasicExecutionContext.getCurrentExecutionContext();
- if (ec!=null) return
ec.submit(taskScheduled);
- else return submit(taskScheduled);
- } finally {
- afterEnd(flags, task);
- }
- }},
- task.delay.toNanoseconds(), TimeUnit.NANOSECONDS);
+ task.result = delayedRunner.schedule(new
ScheduledTaskCallable(task, flags),
+ task.delay.toNanoseconds(), TimeUnit.NANOSECONDS);
} else {
task.endTimeUtc = System.currentTimeMillis();
}
return task;
}
+
+ protected class ScheduledTaskCallable implements Callable<Object> {
+ public ScheduledTask task;
+ public Map<?,?> flags;
+
+ public ScheduledTaskCallable(ScheduledTask task, Map<?, ?> flags) {
+ this.task = task;
+ this.flags = flags;
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public Object call() {
--- End diff --
Incorrect indent.
---
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.
---