Performance: @After and @AfterReturning
MEDIUM IMPACT
These annotations affect the execution timing of aspect code after method calls, impacting CPU usage and response time.
@AfterReturning(pointcut = "execution(* com.example.service.*.*(..))", returning = "result") public void afterReturningAdvice(JoinPoint jp, Object result) { // runs only after successful return lightweightLogging(result); }
@After("execution(* com.example.service.*.*(..))")
public void afterAdvice(JoinPoint jp) {
// runs after method regardless of outcome
heavyLogging();
}| Pattern | CPU Usage | Execution Timing | Impact on Response | Verdict |
|---|---|---|---|---|
| @After (runs always) | High on exceptions | After method regardless of outcome | Can delay error handling | [X] Bad |
| @AfterReturning (runs on success) | Lower CPU usage | Only after successful return | Improves response speed | [OK] Good |