From f7384935042f23aaaf8c0c32f98df78b532d2b86 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 5 Jan 2021 15:05:31 +1100 Subject: [PATCH] Issue #5851 - remove WebSocketServletFactory as ServletContext attribute on destroy Signed-off-by: Lachlan Roberts --- .../eclipse/jetty/websocket/servlet/WebSocketServlet.java | 6 +++--- .../jetty/websocket/servlet/WebSocketServletFactory.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServlet.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServlet.java index 89b20ff8b83..5564b5dd81d 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServlet.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServlet.java @@ -91,7 +91,10 @@ public abstract class WebSocketServlet extends HttpServlet { try { + ServletContext ctx = getServletContext(); + ctx.removeAttribute(WebSocketServletFactory.class.getName()); factory.stop(); + factory = null; } catch (Exception ignore) { @@ -135,11 +138,8 @@ public abstract class WebSocketServlet extends HttpServlet ServletContext ctx = getServletContext(); factory = WebSocketServletFactory.Loader.load(ctx, policy); - configure(factory); - factory.start(); - ctx.setAttribute(WebSocketServletFactory.class.getName(), factory); } catch (Exception x) diff --git a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java index fe103d8b87f..a4729189dec 100644 --- a/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java @@ -43,6 +43,7 @@ public interface WebSocketServletFactory { try { + @SuppressWarnings("unchecked") Class wsClazz = (Class)Class.forName(DEFAULT_IMPL, true, Thread.currentThread().getContextClassLoader()); Constructor ctor = wsClazz.getDeclaredConstructor(ServletContext.class, WebSocketPolicy.class);