-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
2.2.32.Final
-
None
I have this ServletContextListener:
public static class EchoContextListener implements ServletContextListener { static AtomicBoolean INIT = new AtomicBoolean(false); ServletContextEvent sce; @Override public void contextInitialized(ServletContextEvent sce) { INIT.set(true); this.sce = sce; } @Override public void contextDestroyed(ServletContextEvent sce) { INIT.set(false); } }
which I use in my test. This test passes in 2.2.31, but stops working on 2.2.32 and newer 2.2.X versions:
@Test public void echoContextListener() throws IOException, InterruptedException { server.addServletListener(EchoContextListener.class.getName()); server.start(); assertEquals(true, EchoContextListener.INIT.get()); server.stop(); assertEquals(false, EchoContextListener.INIT.get()); }
start() hides the logic to start an embedded undertow server:
@Override public void start() { if (isStarted()) { throw new IllegalStateException("Already started"); } worker = buildXnioWorker(); buildDeploymentManager(); buildPathHandler(); buildAccessLogHandler(); buildUndertow(); undertow.start(); } private void buildDeploymentManager() { deploymentManager = Servlets.newContainer().addDeployment(buildDeploymentInfo()); deploymentManager.deploy(); } private void buildPathHandler() { try { this.pathHandler = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", requireNonNull(deploymentManager).start()); } catch (ServletException e) { throw new RuntimeException(e); } } private void buildAccessLogHandler() { accessLogHandler = new LogHttpHandler(requireNonNull(pathHandler), Predicates.truePredicate()); accessLogHandler.start(); } private void buildUndertow() { undertow = Undertow.builder().addHttpListener(config.getHttpPort(), config.getHost()) .setWorker(requireNonNull(worker)).setDirectBuffers(true).setHandler(requireNonNull(accessLogHandler)) .build(); }
same for stop():
public void stop() { if (!isStarted()) { return; } try { deploymentManager.undeploy(); deploymentManager = null; } finally { try { accessLogHandler.stop(); accessLogHandler = null; } finally { try { undertow.stop(); undertow = null; } finally { worker.shutdown(); worker = null; } } } }
- is caused by
-
UNDERTOW-2351 NullPointerException on flawed WebSockets war deployment
-
- Closed
-