springtomcatspring-bootapr

Spring what is between Controller and Interceptor


I have a controller that is doing something, everything seems fine, it logs a success, and then it does this

return new ResponseEntity<>(resp, HttpStatus.OK);

Seems like it should send a 200 OK.

Well, I also have a HandlerInterceptorAdapter with an "afterCompletion" that logs the status:

logger.debug("Response status: {}, URI: {}", response.getStatus(), request.getRequestURI());

This is showing a 500 where there was a success from the controller.

In the stdout logs I see an error

2018-01-12 12:33:59.035 ERROR 18952 --- [pr-8080-exec-14] o.s.boot.web.support.ErrorPageFilter     : Cannot forward to error page for request [/ws/path] as the response has already been committed.
As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

and

org.apache.catalina.connector.ClientAbortException: java.io.IOException: APR error: -32

I can't find any doc on what that APR error is and I have no idea why the status code would be wrong. I am using tomcat 8.5.


Solution

  • So. APR -32 is a "Client Abort" error. The client was timing out in waiting. It looks like what was happening was the client made a request and was sitting in queue for a few seconds. It has a short hard timeout limit. The client timed out before the server got to the request. Then the server picked up the request and did everything fine but when trying to write back to the client, it found the socket closed. So it set a 500 and threw that exception.