*
*/
public class ThreadLocalLeakPreventionListener implements LifecycleListener,
- ContainerListener {
+ ContainerListener {
+
private static final Log log =
LogFactory.getLog(ThreadLocalLeakPreventionListener.class);
+ private volatile boolean serverStopping = false;
+
/**
* The string manager for this package.
*/
try {
Lifecycle lifecycle = event.getLifecycle();
if (Lifecycle.AFTER_START_EVENT.equals(event.getType()) &&
- lifecycle instanceof Server) {
+ lifecycle instanceof Server) {
// when the server starts, we register ourself as listener for
// all context
// as well as container event listener so that we know when new
registerListenersForServer(server);
}
+ if (Lifecycle.BEFORE_STOP_EVENT.equals(event.getType()) &&
+ lifecycle instanceof Server) {
+ // Server is shutting down, so thread pools will be shut down so
+ // there is no need to clean the threads
+ serverStopping = true;
+ }
+
if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType()) &&
- lifecycle instanceof Context) {
+ lifecycle instanceof Context) {
stopIdleThreads((Context) lifecycle);
}
} catch (Exception e) {
* of its parent Service.
*/
private void stopIdleThreads(Context context) {
+ if (serverStopping) return;
+
if (context instanceof StandardContext &&
!((StandardContext) context).getRenewThreadsWhenStoppingContext()) {
log.debug("Not renewing threads when the context is stopping, "
Improve handling of SSL renegotiation by failing earlier when the
request body contains more bytes than maxSavePostSize. (markt)
</fix>
+ <fix>
+ Improve shut down speed by not renewing threads during shut down when
+ the <code>ThreadLocalLeakPreventionListener</code> is enabled. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">