1. What is the main purpose of CallableProcessingInterceptor?
Why:CallableProcessingInterceptor provides callback methods that are invoked at different stages of asynchronous processing involving a Callable.
2. Which method of CallableProcessingInterceptor is called in the original thread before concurrent handling starts?
Why:beforeConcurrentHandling is invoked before the start of concurrent handling in the original thread that submitted the Callable.
3. Which method is called in the async thread before the Callable is actually invoked?
Why:preProcess is invoked after concurrent handling starts in the async thread, but before the Callable executes.
4. Which method is called after the Callable has produced a result?
Why:postProcess is invoked after the Callable has produced a result in the async thread.
5. What should handleTimeout return to indicate that no result should be used?
Why: The constant RESULT_NONE is returned from handleTimeout to signal that no result is available.
6. Which method was added to CallableProcessingInterceptor in Spring 5.0 to handle errors?
Why:handleError was introduced in Spring 5.0 to allow interception of errors during async processing.
7. How can you register a CallableProcessingInterceptor for a specific request?
Why: A CallableProcessingInterceptor is registered programmatically through WebAsyncManager.registerCallableInterceptor.
8. What is a key difference between CallableProcessingInterceptor and AsyncHandlerInterceptor?
Why:CallableProcessingInterceptor offers deeper integration with the async lifecycle, including callbacks before, during, and after the Callable runs.
9. In which thread is afterCompletion of CallableProcessingInterceptor typically invoked?
Why:afterCompletion is called from a container thread when async processing finishes, and this thread may not be the original request thread.
10. Given the following partial interceptor, which method is missing to handle a timeout?
public class MyInterceptor implements CallableProcessingInterceptor {
@Override
public void beforeConcurrentHandling(
NativeWebRequest request, Callable task) { }
// missing method
}
Why: The correct signature for the timeout callback is public Object handleTimeout(NativeWebRequest request, Callable task), and it should return RESULT_NONE.
11. What is the correct return type of the preProcess method?
Why:preProcess is declared as void preProcess(NativeWebRequest request, Callable task).
12. Which method would you override to log a message immediately after the async task finishes?
Why:postProcess is invoked right after the Callable completes and produces a result.
13. What is the correct parameter list for the postProcess method?
Why:postProcess receives the NativeWebRequest, the Callable, and the result produced by the Callable.
14. Which method is called from a container thread when an error occurs during async processing before the Callable completes?
Why:handleError is invoked from a container thread when an error occurs while processing the async request.
15. Which of the following methods is NOT part of the CallableProcessingInterceptor interface?
Why:afterConcurrentHandlingStarted belongs to AsyncHandlerInterceptor, not CallableProcessingInterceptor.