As stated in title, what does it mean that HttpServletResponse is committed?
I have some request interceptor, extending HandlerInterceptorAdapter
, that overrides postHandle
method. Post handle method takes parameter final HttpServletResponse response
. In method body there is an if
statement checking if response.isCommitted()
, what exactly does that check?
private static final String voidResponse = "null";
@Override
public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler,
final ModelAndView modelAndView) throws IOException {
if (!response.isCommitted()) {
if (DefaultServletHttpRequestHandler.class == handler.getClass()) {
return;
}
response.setStatus(200);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
try (final Writer writer = response.getWriter()) {
writer.write(voidResponse);
}
log.info("void method called, respond with 200 and null");
response.flushBuffer();
}
}