423646 - WebSocket / JSR / WebSocketContainer (Client) should have its LifeCycle stop on standalone use
+ Set Daemon on Executor and Scheduler threads to allow them to shutdown with the JVM
This commit is contained in:
parent
f0eeb27921
commit
44a7d23516
|
@ -83,7 +83,9 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
|
|||
|
||||
public ClientContainer()
|
||||
{
|
||||
// This constructor is used with Standalone JSR Client usage.
|
||||
this(null);
|
||||
client.setDaemon(true);
|
||||
}
|
||||
|
||||
public ClientContainer(Executor executor)
|
||||
|
|
|
@ -72,6 +72,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
private final WebSocketPolicy policy;
|
||||
private final SslContextFactory sslContextFactory;
|
||||
private final WebSocketExtensionFactory extensionRegistry;
|
||||
private boolean daemon = false;
|
||||
private EventDriverFactory eventDriverFactory;
|
||||
private SessionFactory sessionFactory;
|
||||
private Set<WebSocketSession> openSessions = new CopyOnWriteArraySet<>();
|
||||
|
@ -227,7 +228,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
|
||||
if (scheduler == null)
|
||||
{
|
||||
scheduler = new ScheduledExecutorScheduler(name + "-scheduler",false);
|
||||
scheduler = new ScheduledExecutorScheduler(name + "-scheduler",daemon);
|
||||
}
|
||||
addBean(scheduler);
|
||||
|
||||
|
@ -290,7 +291,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
{
|
||||
return cookieStore;
|
||||
}
|
||||
|
||||
|
||||
public EventDriverFactory getEventDriverFactory()
|
||||
{
|
||||
return eventDriverFactory;
|
||||
|
@ -419,6 +420,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
String name = WebSocketClient.class.getSimpleName() + "@" + hashCode();
|
||||
threadPool.setName(name);
|
||||
threadPool.setDaemon(daemon);
|
||||
executor = threadPool;
|
||||
addBean(executor,true);
|
||||
}
|
||||
|
@ -505,6 +507,11 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
|
|||
{
|
||||
this.cookieStore = cookieStore;
|
||||
}
|
||||
|
||||
public void setDaemon(boolean daemon)
|
||||
{
|
||||
this.daemon = daemon;
|
||||
}
|
||||
|
||||
public void setEventDriverFactory(EventDriverFactory factory)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue