Bird
0
0

Identify the error in this @Around advice method:

medium📝 Debug Q14 of 15
Spring Boot - Aspect-Oriented Programming
Identify the error in this @Around advice method:
@Around("execution(* someMethod())")
public Object aroundAdvice(ProceedingJoinPoint joinPoint) {
    System.out.println("Start");
    Object result = joinPoint.proceed();
    System.out.println("End");
    return result;
}
AIncorrect annotation syntax
BMissing throws Throwable declaration in method signature
CShould call joinPoint.execute() instead of proceed()
DCannot return Object type from advice
Step-by-Step Solution
Solution:
  1. Step 1: Check method signature requirements

    joinPoint.proceed() throws Throwable, so the advice method must declare throws Throwable or handle it.
  2. Step 2: Identify missing throws declaration

    The method lacks "throws Throwable", causing a compile error.
  3. Final Answer:

    Missing throws Throwable declaration in method signature -> Option B
  4. Quick Check:

    proceed() throws Throwable, must declare it [OK]
Quick Trick: Add throws Throwable when calling joinPoint.proceed() [OK]
Common Mistakes:
  • Ignoring checked exceptions from proceed()
  • Using wrong method name instead of proceed()
  • Not matching annotation syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes