I have a small piece of code. Rest controller
@RestController
public class GreetingController {
@RequestMapping("/greeting")
public String greeting() {
return "greeting";
}
}
and aspect
@Aspect
@Component
public class Audience {
@Around("execution(** com.fire.example.GreetingController.greeting(..))")
public void silenceCellPhones(ProceedingJoinPoint jp) {
try {
System.out.println("Before call");
jp.proceed();
System.out.println("After call");
} catch (Throwable e) {
e.printStackTrace();
}
}
}
And I don't know why, but rest controller works well without aspect and doesn't work with it. In case of using @After and @Before rest also works well. When I say rest doesn't work I mean there is no response returned.
I would appreciate any idea.
An around advice has to return (as Object) the result of the .proceed()-method or you are removing the return value.