Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Null HttpChannel.getCurrentHttpChannel() in ServletHandler.doFilter()

Are you using ProxyServlet ?

http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/proxy/ProxyServlet.html

or AsyncProxyServlet ?

http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/proxy/AsyncProxyServlet.html

Generally, accessing the raw Jetty internal Request object is a bad idea.
There so many potential levels and wrappers in the way that accessing that object is often impossible or impractical from a filter.
If you can use the ServletRequest and/or HttpServletRequest then do so.

It might make more sense to just use the AsyncProxyServlet instead.

Also note that the HttpChannel concepts are not guaranteed to be the same once HTTP/2 is in the picture.
Since with HTTP/2 you have 1 physical connection with multiple HTTP/2 streams + requests.
We're still working on HTTP/2, so this statement isn't written in stone.  (see the jetty-http2 branch)


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Fri, Jul 18, 2014 at 6:36 AM, Matt Deimel <mdeimel@xxxxxxxxx> wrote:
I'm attempting to make SiteMesh3 an asynchronous filter so that it will work with Jetty's asynchronous ProxyServlet.Transparent proxy. Everything appears to work until the SiteMesh filter hands off to Jetty - specifically in ServletHandler.doFilter(). The NullPointerException happens on the first line of that method (line 1628 for jetty-proxy 9.2.1.v20140609). When I debug into it I see that the request is *not* an instance of Request, and HttpChannel.getCurrentHttpChannel() is null, which is why it throws a NPE when trying to call getRequest(). 

My question is this - is there any way for me to initialize or setup HttpChannel, or is that completely outside of what I should be doing when I use the Jetty proxy? Thanks so much for your help. 

        @Override
        public void doFilter(ServletRequest request, ServletResponse response)
            throws IOException, ServletException
        {
            final Request baseRequest=(request instanceof Request)?((Request)request):HttpChannel.getCurrentHttpChannel().getRequest();

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top