Merge pull request #5860 from eclipse/jetty-9.4.x-5851-WebSocketServletCleanup
Issue #5851 - remove WebSocketServletFactory as ServletContext attribute on destroy
This commit is contained in:
commit
759805580b
|
@ -91,7 +91,10 @@ public abstract class WebSocketServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ServletContext ctx = getServletContext();
|
||||||
|
ctx.removeAttribute(WebSocketServletFactory.class.getName());
|
||||||
factory.stop();
|
factory.stop();
|
||||||
|
factory = null;
|
||||||
}
|
}
|
||||||
catch (Exception ignore)
|
catch (Exception ignore)
|
||||||
{
|
{
|
||||||
|
@ -135,11 +138,8 @@ public abstract class WebSocketServlet extends HttpServlet
|
||||||
|
|
||||||
ServletContext ctx = getServletContext();
|
ServletContext ctx = getServletContext();
|
||||||
factory = WebSocketServletFactory.Loader.load(ctx, policy);
|
factory = WebSocketServletFactory.Loader.load(ctx, policy);
|
||||||
|
|
||||||
configure(factory);
|
configure(factory);
|
||||||
|
|
||||||
factory.start();
|
factory.start();
|
||||||
|
|
||||||
ctx.setAttribute(WebSocketServletFactory.class.getName(), factory);
|
ctx.setAttribute(WebSocketServletFactory.class.getName(), factory);
|
||||||
}
|
}
|
||||||
catch (Exception x)
|
catch (Exception x)
|
||||||
|
|
|
@ -43,6 +43,7 @@ public interface WebSocketServletFactory
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends WebSocketServletFactory> wsClazz =
|
Class<? extends WebSocketServletFactory> wsClazz =
|
||||||
(Class<? extends WebSocketServletFactory>)Class.forName(DEFAULT_IMPL, true, Thread.currentThread().getContextClassLoader());
|
(Class<? extends WebSocketServletFactory>)Class.forName(DEFAULT_IMPL, true, Thread.currentThread().getContextClassLoader());
|
||||||
Constructor<? extends WebSocketServletFactory> ctor = wsClazz.getDeclaredConstructor(ServletContext.class, WebSocketPolicy.class);
|
Constructor<? extends WebSocketServletFactory> ctor = wsClazz.getDeclaredConstructor(ServletContext.class, WebSocketPolicy.class);
|
||||||
|
|
Loading…
Reference in New Issue