version : spring-boot-starter 2.1.3
I am using @Async annotation like this.
@Async("executorBean")
public CompletableFuture<Map<String, Integer>> callApi() {
....
}
and tracking it with my logging aspect
@Pointcut("execution(* *.callApi(..))")
public void callApiPointCut() {
}
@After("callApiPointCut()")
public void callCountApiLogger(JoinPoint joinPoint){
}
It works pretty well :)
=================================================
But if I changed an AOP advice to @Around, it doesn't work.
@Around("callApiPointCut()")
public void callCountApiLogger(ProceedingJoinPoint pjp){
pjp.proceed();
}
There are screenshots of my debugging console.
@After
@Around
I think the reason why it doesn't work is @Around needs to call proceed() manually.
Does anyone else have the same issue as me?
Comment From: mdeinum
The reason is that your @Around
advice is flawed. Making that return void
breaks the method, it will now return null
and not your CompletableFuture
. Instead your advice should look like
@Around("callApiPointCut()") public Object callCountApiLogger(ProceedingJoinPoint pjp){ return pjp.proceed(); }
Notice the Object
return type and the returning of the pjp.proceed();
result.
Comment From: ggthename
Thank you so much! It was rudimentary mistake.