Suppose that endpoint handler manipulates with HttpServletResponse directly and returns no entity:
In this case unfortunately ServerResponseWriter overwrites status code to 204 (see line 91), which is not desired, as the client gets HTTP 204 and non-empty body (note that body is small enough to be buffered).
Is it possible for ServerResponseWriter to learn that the body is already written? If not, consider the following workaround in which the handler should commit the response:
In this case the corresponding code in ServerResponseWriter can be: