Bird
0
0

What is wrong with this @Around advice implementation?

medium📝 Debug Q7 of 15
Spring Boot - Aspect-Oriented Programming
What is wrong with this @Around advice implementation?
@Around("execution(* com.example..*(..))")
public Object advice(ProceedingJoinPoint pjp) throws Throwable {
  System.out.println("Start");
  Object result = pjp.proceed();
  System.out.println("End");
  return null;
}
AIncorrect pointcut expression syntax
BMissing try-catch block around proceed()
CNo issues, this is valid advice
DReturning null instead of the actual method result causes issues
Step-by-Step Solution
Solution:
  1. Step 1: Analyze return value usage

    The advice returns null instead of the original method's result, breaking expected behavior.
  2. Step 2: Consider impact on caller

    Caller expecting method result will get null, likely causing errors or unexpected behavior.
  3. Final Answer:

    Returning null instead of the actual method result causes issues -> Option D
  4. Quick Check:

    Always return proceed() result in @Around advice [OK]
Quick Trick: Return the proceed() result to preserve method output [OK]
Common Mistakes:
  • Returning null instead of proceed() result
  • Assuming proceed() result can be ignored
  • Not understanding impact on method callers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes