[resteasy] Imprecise http status code when a requested media type is not available
Katerina Novotna
kanovotn at redhat.com
Fri Sep 23 07:08:23 EDT 2016
Hi Yonghee,
thanks for raising this. I have created resteasy jira for this problem - https://issues.jboss.org/browse/RESTEASY-1507.
-- Katka
----- Original Message -----
From: "Yonghee Shin" <syonghee at gmail.com>
To: resteasy at lists.jboss.org
Sent: Wednesday, September 14, 2016 10:40:25 PM
Subject: [resteasy] Imprecise http status code when a requested media type is not available
Hi,
When the requested media type in the "Accept" http header is not available on the server side, currently http status 500 is returned instead of 406 (Not Acceptable).
I traced the code and a simple change below in org.jboss.resteasy.springmvc.ResteasyHandlerMapping.getHandler(HttpServletRequest request) made it return the proper code:
catch (NotFoundException e)
{
if (throwNotFound)
{
throw e;
}
logger.error("Resource Not Found: " + e.getMessage(), e);
}
catch (NotAcceptableException na) { // Added this exception handler
logger.error("Not acceptable: " + na.getMessage(), na);
requestWrapper.setError(406, "The requested media type is not acceptable.");
return new HandlerExecutionChain(requestWrapper, interceptors);
}
catch (Failure e)
I'm using resteasy-spring-2.3.7.jar.
Is there any newer version that already addresses this issue or would it be possible to enhance the code in the future release?
I appreciate your help.
Yonghee
_______________________________________________
resteasy mailing list
resteasy at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/resteasy
More information about the resteasy
mailing list