I am using suspend/complete model for processing a request. continuation.suspend() is called once the request is dispatched asynchronously and continuation.complete() is called on response.
I tried registering a listener with the continuation and onCompletion is called once the complete is executed. The response is written as part of onCompletion and we see that the response is written to the client properly.
We see below description for onComplete.
Called when a continuation life cycle is complete and after any calls to
ServletRequestListener.requestDestroyed(javax.servlet.ServletRequestEvent) The response may still be written to during the call.
Can we use onComplete method to write the response to client or will it have any race condition that may lead to response not getting written to client?