2012/5/13  <ma...@apache.org>:
> Author: markt
> Date: Sat May 12 20:51:24 2012
> New Revision: 1337643
>
> URL: http://svn.apache.org/viewvc?rev=1337643&view=rev
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53067
> Make sure request is unwrapped before we cast it to the internal Tomcat 
> implementation
>
> Modified:
>    tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java
>
> Modified: 
> tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java?rev=1337643&r1=1337642&r2=1337643&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java 
> (original)
> +++ tomcat/trunk/java/org/apache/catalina/websocket/WebSocketServlet.java Sat 
> May 12 20:51:24 2012
> @@ -27,6 +27,8 @@ import java.util.Queue;
>  import java.util.concurrent.ConcurrentLinkedQueue;
>
>  import javax.servlet.ServletException;
> +import javax.servlet.ServletRequest;
> +import javax.servlet.ServletRequestWrapper;
>  import javax.servlet.http.HttpServlet;
>  import javax.servlet.http.HttpServletRequest;
>  import javax.servlet.http.HttpServletResponse;
> @@ -112,9 +114,19 @@ public abstract class WebSocketServlet e
>             // TODO
>         }
>
> -        // Small hack until the Servlet API provides a way to do this.
>         StreamInbound inbound = createWebSocketInbound(subProtocol);
> -        ((RequestFacade) req).doUpgrade(inbound);
> +
> +        // Small hack until the Servlet API provides a way to do this.
> +        ServletRequest inner = req;
> +        // Unwrap the request
> +        while (inner instanceof ServletRequestWrapper) {
> +            inner = ((ServletRequestWrapper) inner).getRequest();
> +        }
> +        if (inner instanceof RequestFacade) {
> +            ((RequestFacade) req).doUpgrade(inbound);

inner.doUpgrade(), not req.

> +        } else {
> +            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

It would be hard to find what is the cause of an issue if it is just a
generic error 500.

Maybe just throw a ServletException and let the ErrorReportValve to
handle the rest?
Well, just blatantly casting to RequestFacade will do effectively the same.

> +        }
>     }
>

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to