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()

Joakim - thanks for your response.

I have been using ProxyServlet.Transparent, but I see the same result if I use AsyncProxyServlet or AsyncProxyServlet.Transparent

I'm actually creating a subclass of ProxyServlet.Transparent so that I can change how the AsyncContext is started. Currently it is started with "request.startAsync()", which I believe will overwrite the async context that was started by a filter. So I change that to first check if isAsyncStarted(), and if so, then call request.getAsyncContext() to make use of the existing context. I'm not 100% sure of this is a Jetty bug, or if the proxy needs to ignore any existing AsyncContext.

Thanks.


On Fri, Jul 18, 2014 at 10:31 AM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
Are you using ProxyServlet ?



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


_______________________________________________
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