You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/04/22 10:32:51 UTC
svn commit: r1589044 - in /tomcat/tc7.0.x/trunk: ./
java/org/apache/tomcat/websocket/server/ webapps/docs/
Author: markt
Date: Tue Apr 22 08:32:50 2014
New Revision: 1589044
URL: http://svn.apache.org/r1589044
Log:
Refactor server container shutdown into the destroy method
Destroy the thread group on shutdown
Log a warning if the thread group can't be destroyed
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsContextListener.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1589043
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties?rev=1589044&r1=1589043&r2=1589044&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties Tue Apr 22 08:32:50 2014
@@ -24,6 +24,7 @@ serverContainer.missingEndpoint=An Endpo
serverContainer.pojoDeploy=POJO class [{0}] deploying to path [{1}] in ServletContext [{2}]
serverContainer.servletContextMismatch=Attempted to register a POJO annotated for WebSocket at path [{0}] in the ServletContext with context path [{1}] when the WebSocket ServerContainer is allocated to the ServletContext with context path [{2}]
serverContainer.servletContextMissing=No ServletContext was specified
+serverContainer.threadGroupNotDestroyed=Unable to destroy WebSocket thread group [{0}] as some threads were still running when the web application was stopped
uriTemplate.duplicateParameter=The parameter [{0}] appears more than once in the path which is not permitted
uriTemplate.emptySegment=The path [{0}] contains one or more empty segments which are is not permitted
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsContextListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsContextListener.java?rev=1589044&r1=1589043&r2=1589044&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsContextListener.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsContextListener.java Tue Apr 22 08:32:50 2014
@@ -45,7 +45,6 @@ public class WsContextListener implement
ServletContext sc = sce.getServletContext();
Object obj = sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
if (obj instanceof WsServerContainer) {
- ((WsServerContainer) obj).shutdownExecutor();
((WsServerContainer) obj).destroy();
}
}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1589044&r1=1589043&r2=1589044&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Tue Apr 22 08:32:50 2014
@@ -49,6 +49,8 @@ import javax.websocket.server.ServerEndp
import javax.websocket.server.ServerEndpointConfig;
import javax.websocket.server.ServerEndpointConfig.Configurator;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.res.StringManager;
import org.apache.tomcat.websocket.WsSession;
import org.apache.tomcat.websocket.WsWebSocketContainer;
@@ -70,6 +72,8 @@ public class WsServerContainer extends W
private static final StringManager sm =
StringManager.getManager(Constants.PACKAGE_NAME);
+ private static final Log log = LogFactory.getLog(WsServerContainer.class);
+
private static final CloseReason AUTHENTICATED_HTTP_SESSION_CLOSED =
new CloseReason(CloseCodes.VIOLATED_POLICY,
"This connection was established under an authenticated " +
@@ -88,6 +92,7 @@ public class WsServerContainer extends W
private final ConcurrentHashMap<String,Set<WsSession>> authenticatedSessions =
new ConcurrentHashMap<String, Set<WsSession>>();
private final ExecutorService executorService;
+ private final ThreadGroup threadGroup;
private volatile boolean endpointsRegistered = false;
WsServerContainer(ServletContext servletContext) {
@@ -150,7 +155,7 @@ public class WsServerContainer extends W
} else {
threadGroupName.append(servletContext.getContextPath());
}
- ThreadGroup threadGroup = new ThreadGroup(threadGroupName.toString());
+ threadGroup = new ThreadGroup(threadGroupName.toString());
WsThreadFactory wsThreadFactory = new WsThreadFactory(threadGroup);
executorService = new ThreadPoolExecutor(executorCoreSize,
@@ -273,6 +278,21 @@ public class WsServerContainer extends W
}
+ @Override
+ public void destroy() {
+ shutdownExecutor();
+ super.destroy();
+ try {
+ threadGroup.destroy();
+ } catch (IllegalThreadStateException itse) {
+ // If the executor hasn't fully shutdown it won't be possible to
+ // destroy this thread group as there will still be threads running
+ log.warn(sm.getString("serverContainer.threadGroupNotDestroyed",
+ threadGroup.getName()));
+ }
+ }
+
+
boolean areEndpointsRegistered() {
return endpointsRegistered;
}
@@ -442,7 +462,7 @@ public class WsServerContainer extends W
}
- void shutdownExecutor() {
+ private void shutdownExecutor() {
if (executorService == null) {
return;
}
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1589044&r1=1589043&r2=1589044&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Apr 22 08:32:50 2014
@@ -162,6 +162,11 @@
implementation for call backs associated with asynchronous writes from
10 to 200. (markt)
</fix>
+ <add>
+ Add a warning if the thread group created for WebSocket asynchronous
+ write call backs can not be destroyed when the web application is
+ stopped. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org