Unmanage beans on WSSComponents if they are also beans on server.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-03-30 17:50:55 +11:00
parent b51e40892d
commit 16b014c2fb
2 changed files with 5 additions and 5 deletions

View File

@ -83,11 +83,11 @@ public class WebSocketServerComponents extends WebSocketComponents
// These components may be managed by the server but not yet started. // These components may be managed by the server but not yet started.
// In this case we don't want them to be managed by the components as well. // In this case we don't want them to be managed by the components as well.
if (server.isManaged(inflaterPool)) if (server.contains(inflaterPool))
serverComponents.unmanage(inflaterPool); serverComponents.unmanage(inflaterPool);
if (server.isManaged(deflaterPool)) if (server.contains(deflaterPool))
serverComponents.unmanage(deflaterPool); serverComponents.unmanage(deflaterPool);
if (server.isManaged(bufferPool)) if (server.contains(bufferPool))
serverComponents.unmanage(bufferPool); serverComponents.unmanage(bufferPool);
servletContext.setAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE, serverComponents); servletContext.setAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE, serverComponents);

View File

@ -124,8 +124,8 @@ public class WebSocketServerComponentsTest
// Use a custom InflaterPool and DeflaterPool that are not started or managed. // Use a custom InflaterPool and DeflaterPool that are not started or managed.
InflaterPool inflaterPool = new InflaterPool(333, false); InflaterPool inflaterPool = new InflaterPool(333, false);
DeflaterPool deflaterPool = new DeflaterPool(333, Deflater.BEST_SPEED, false); DeflaterPool deflaterPool = new DeflaterPool(333, Deflater.BEST_SPEED, false);
server.addManaged(inflaterPool); server.addBean(inflaterPool);
server.addManaged(deflaterPool); server.addBean(deflaterPool);
// ensureWebSocketComponents can only be called when the server is starting. // ensureWebSocketComponents can only be called when the server is starting.
contextHandler.addServletContainerInitializer(new ServletContainerInitializerHolder((c, ctx) -> contextHandler.addServletContainerInitializer(new ServletContainerInitializerHolder((c, ctx) ->