[ https://issues.apache.org/jira/browse/HADOOP-9613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14973815#comment-14973815 ]
Tsuyoshi Ozawa commented on HADOOP-9613: ---------------------------------------- Steve, thank you for taking a look. {quote} Why so many duplicate guice servlet context classes? {quote} It's for sharing an object of com.google.inject.Injector within test classes. The test cases which extends JerseyTest are initialized in its constructor, which accepts a guice servlet context class. {code} public TestAMWebServices() { super(new WebAppDescriptor.Builder( "org.apache.hadoop.mapreduce.v2.app.webapp") .contextListenerClass(GuiceServletConfig.class) // <-- servlet context class .filterClass(com.google.inject.servlet.GuiceFilter.class) .contextPath("jersey-guice-filter").servletPath("/").build()); } {code} The guice servlet context classes are used to initialize JerseyTest and servlet containers with guice's DI: {code} private Injector injector = Guice.createInjector(new ServletModule() { @Override protected void configureServlets() { appContext = new MockAppContext(0, 1, 1, 1); appContext.setBlacklistedNodes(Sets.newHashSet("badnode1", "badnode2")); bind(JAXBContextResolver.class); bind(AMWebServices.class); bind(GenericExceptionHandler.class); serve("/*").with(GuiceContainer.class); } } public class GuiceServletConfig extends GuiceServletContextListener { @Override protected Injector getInjector() { return injector; } } {code} The latest patch fixes test failures by changes of the initialization sequence after upgrading jersey-test-framework-grizzly2 to 1.13 or later. It happens because grizzly2 has started to use reflection since 2.2.16 and the logic to create ServletModule in Webappcontext doesn't handle [formal parameter|https://issues.apache.org/jira/browse/HADOOP-9613?focusedCommentId=14573457&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14573457] of inner class. I thought it's better to make these inner classes static, but it happens test failures because some test changes states of servlets and the states remain still after executing tests. That's why I changed GuiceServletConfig to normal class(not inner class) and be able to initialize its module for each test cases as follows. {code} static { GuiceServletConfig.injector = Guice.createInjector(new WebServletModule()); } @Before @Override public void setUp() throws Exception { super.setUp(); GuiceServletConfig.injector = Guice.createInjector(new WebServletModule()); } {code}] > [JDK8] Update jersey version to latest 1.x release > -------------------------------------------------- > > Key: HADOOP-9613 > URL: https://issues.apache.org/jira/browse/HADOOP-9613 > Project: Hadoop Common > Issue Type: Sub-task > Components: build > Affects Versions: 2.4.0, 3.0.0 > Reporter: Timothy St. Clair > Assignee: Tsuyoshi Ozawa > Labels: maven > Attachments: HADOOP-2.2.0-9613.patch, > HADOOP-9613.004.incompatible.patch, HADOOP-9613.005.incompatible.patch, > HADOOP-9613.1.patch, HADOOP-9613.2.patch, HADOOP-9613.3.patch, > HADOOP-9613.patch > > > Update pom.xml dependencies exposed when running a mvn-rpmbuild against > system dependencies on Fedora 18. > The existing version is 1.8 which is quite old. -- This message was sent by Atlassian JIRA (v6.3.4#6332)