-
Couldn't load subscription status.
- Fork 38.8k
Description
Daniel Gonzalez opened SPR-12895 and commented
When using @Async annotation to create an async execution for a method ListenableFuture is one of the options that could be used as return type in the method as it seems to be supported by all the spring async aspect code.
On aspect AnnotationAsyncExecutionAspect.aj the pointcut to intercept async annotations classes is as follows:
private pointcut asyncMarkedMethod()
: execution(@Async (void || Future+) *(..));
Which accepts Future or one of its subclasses as return type.
But then in the same class a compiler error is declared that only accepts Future:
declare error:
execution(@Async !(void||Future) *(..)):
"Only methods that return void or Future may have an @Async annotation";
This declarations causes that when I used something like:
@Async
public ListenableFuture execute() {
...
return new AsyncResult();
}
Fails with a compiler error.
Also I cannot used the plain Future as then I cannot add callback handlers to the future. I always can call the task manager directly but as it seems that it is a feature that it is supported by the annotation I would prefer to do that as I'm using it in other places on the application without any issue.
Affects: 4.1.6