I am trying to log HttpServletRequest content through aop in async mode. The method on which pointcut in implement has HttpServletRequest as method argument. I am not able to access it in async mode, though the code works fine without the @Async annotation.
@Async
@AfterReturning(pointcut = "execution(* com.web.dto.util.response.impl.ResponseImpl.prepareResponseDTO(..))", returning = "object")
public void logSearchJSON(JoinPoint joinPoint, final Object object) {
try {
List<Object> objects = getActivityParams(joinPoint);
UserActivity userPersonalization = null;
HttpServletRequest httpServletRequest = (HttpServletRequest) objects.get(0);
if (httpServletRequest.getRequestURI().contains(UserActivityConstant.filter))
httpServletRequest.getRequestURI() returns null.
It was working fine without the @Async annotation