users@jersey.java.net

Re: If a resource (or provider?) throws a ClassCastException, users get the exception "non-HTTP request or response"

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 08 Jun 2009 11:34:20 +0200

[Moving over to the users list]

On Jun 6, 2009, at 11:19 AM, Matt Savage wrote:

> My bad- typo searching for ClassCastException in the archives.
>
> Resolved in Issue 204 I believe.
>

Correct!

Paul.

>
> 2009/6/6 Matt Savage <matthew.savage_at_gmail.com>
> If a resource throws a ClassCastException, users get the confusing
> exception "non-HTTP request or response".
>
> In ServletContainer:
>
> public void service(ServletRequest request, ServletResponse
> response) throws ServletException, IOException {
> try {
> service((HttpServletRequest) request,
> (HttpServletResponse) response);
> } catch (ClassCastException e) {
> throw new ServletException("non-HTTP request or
> response");
> }
> }
>
> Needs to change to something like:
>
> public void service(ServletRequest request, ServletResponse
> response) throws ServletException, IOException {
> HttpServletRequest httpRequest;
> HttpServletResponse httpResponse;
> try {
> httpRequest = (HttpServletRequest) request;
> httpResponse = (HttpServletResponse) response;
> } catch (ClassCastException e) {
> throw new ServletException("non-HTTP request or
> response");
> }
> service(httpRequest httpResponse);
> }
>
>