Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/853#discussion_r142933756
--- Diff:
core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionContext.java
---
@@ -242,16 +244,40 @@ public synchronized T get(long timeout, TimeUnit
unit) throws InterruptedExcepti
}
}
+ @Override
+ public <T> Maybe<T> getImmediately(TaskFactory<Task<T>>
callableOrSupplier) {
+ return getImmediatelyInternal(callableOrSupplier);
+ }
+
+ @Override
+ public <T> Maybe<T> getImmediately(TaskAdaptable<T>
callableOrSupplier) {
+ if (!(callableOrSupplier instanceof TaskFactory)) {
+ Task<T> t = callableOrSupplier.asTask();
+ if (!t.isSubmitted()) {
+ log.warn("Deprecated call to getImmediately on unsubmitted
task "+callableOrSupplier+"; "
+ + "this will run the task in a crippled state. Pass a
TaskFactory instead or submit the task beforehand.");
+ log.debug("Trace for deprecated call to
getImmediately("+callableOrSupplier+")",
+ new Exception("Trace for deprecated call to
getImmediately("+callableOrSupplier+")"));
+ }
+ }
+ return getImmediatelyInternal(callableOrSupplier);
+ }
+
/** performs execution without spawning a new task thread, though it
does temporarily set a fake task for the purpose of getting context;
- * currently supports {@link Supplier}, {@link Callable}, {@link
Runnable}, or {@link Task} instances;
+ * currently supports {@link Supplier}, {@link Callable}, {@link
Runnable},
+ * or {@link Task} (recommended to be {@link TaskFactory}) instances;
* with tasks if it is submitted or in progress,
* it fails if not completed; with unsubmitted, unqueued tasks, it
gets the {@link Callable} job and
* uses that; with such a job, or any other
callable/supplier/runnable, it runs that
* in an {@link InterruptingImmediateSupplier}, with as much metadata
as possible (eg task name if
* given a task) set <i>temporarily</i> in the current thread context
*/
- @SuppressWarnings("unchecked")
@Override
public <T> Maybe<T> getImmediately(Object callableOrSupplier) {
--- End diff --
Would like to say that passing in a `Task` is deprecated.
---