Bird
0
0

Analyze this Spring Boot async method:

medium📝 Debug Q6 of 15
Spring Boot - Async Processing

Analyze this Spring Boot async method:

@Async
public void performTask() {
  throw new IllegalStateException("Failure");
}

What is the expected behavior when performTask() is called?

AThe method retries automatically on exception
BThe exception is thrown to the caller immediately
CThe exception is logged but not propagated to the caller
DThe exception is ignored silently
Step-by-Step Solution
Solution:
  1. Step 1: Exception handling in async void methods

    Exceptions thrown in async void methods are caught by Spring's async executor and logged.
  2. Step 2: Caller does not receive exception

    Since the method returns void, the caller does not get the exception propagated.
  3. Final Answer:

    The exception is logged but not propagated to the caller -> Option C
  4. Quick Check:

    Async void exceptions are logged, not thrown to caller [OK]
Quick Trick: Exceptions in async void methods are logged, not thrown [OK]
Common Mistakes:
  • Expecting exceptions to propagate to caller
  • Assuming automatic retries on exception
  • Thinking exceptions are ignored silently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes