I am using spring MVC framework. I want to log error statuses whenever exception is thrown, so afterCompletion
method is used in HanlderInterceptor
.
@Override
public void afterCompletion( final HttpServletRequest request, final HttpServletResponse response, final Object handler, final Exception ex)
{
final int responseCode = response.getStatus();
s_logger_error.error("status code: " + responseCode );
}
This code works fine if I run this as an application on local machine. But when we host it on the jetty server, UI gets correct error response (In my case 409
), but in this method it gets logged as 200
.
[Image from remote debug where it shows status=200
but in response it is 409
]
Can somebody help to figure out why there is change in the response code?
I am using sprint 1.1.7.RELEASE spring boot version and jetty-distribution-9.2.10.v20150310.