google / google/guice

GuiceFilter uses wrong instance of FilterPipeline if used with multiple servlet context and multiple injectors

Open
#635 34 comments 0 reactions 0 assignees View on GitHub
imported
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

_From [carsten.schipke](https://code.google.com/u/107139061012626663823/) on June 07, 2011 21:57:53_

In short:

Servlet Container: Jetty 8.0.0 M3
Guice: 3.0 + Servlet Extension (3.0)

If i create multiple servlet context and configure each of them with a dedicated injector based on a dedicated servlet module, GuiceFilter aquires always the FilterPipeline according to the last added servlet context/injector - no matter which servlet context my HTTP request leads to.

e.g.

Servlet Context A (context path: /a)
Configured with dedicated GuiceFilter & GuiceServletContextListener providing Injector holding
    Servlet Module incl. serve("/hello", HelloAServlet.class)

Servlet Context B (context path: /b)
Configured with dedicated GuiceFilter & GuiceServletContextListener providing Injector holding
    Servlet Module incl. serve("/hello", HelloBServlet.class)

If i add mentioned context in listed order, i will always receive HelloBServlet.class, no matter if i invoke /hello/a - or /hello/b in my browser.

I did not spend much time yet to find a clean solution, but what i can say is that some debugging in GuiceFilter tells me that it somehow uses the wrong (Managed)FilterPipeline on request / GuiceFilter.doFilter - but it is associated to the correct servlet context.

So if (i know, not clean solution) i extend GuiceFilter.setPipeline to put the here given FilterPipeline (which is still correct at this time) into provided servlet context AND then use this pipeline again in GuiceFilter.doFilter - all problems are solved.

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=635_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.