Bird
0
0

What happens if a @Before advice method throws an exception during execution?

medium📝 Predict Output Q5 of 15
Spring Boot - Aspect-Oriented Programming
What happens if a @Before advice method throws an exception during execution?
AThe advice is retried until it succeeds before running the target method
BThe target method is not executed and the exception propagates
CThe exception is caught and logged, then the target method runs
DThe target method executes normally ignoring the exception
Step-by-Step Solution
Solution:
  1. Step 1: Understand exception handling in @Before advice

    If @Before advice throws an exception, it prevents the target method from running.
  2. Step 2: Confirm exception propagation behavior

    The exception propagates up, stopping normal flow unless caught elsewhere.
  3. Final Answer:

    The target method is not executed and the exception propagates -> Option B
  4. Quick Check:

    @Before exception stops target method [OK]
Quick Trick: Exception in @Before stops target method execution [OK]
Common Mistakes:
  • Thinking target method runs despite advice exception
  • Assuming automatic retry of advice
  • Believing exception is silently ignored

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes