From a8d07128a56196b29ce11dad9f1e3167ff9945ac Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 1 Jul 2011 22:47:46 +0000 Subject: [PATCH] When using Servlets that implement the SingleThreadModel interface, add the single instance created to the pool when it is determined that a pool of servlets is required rather than throwing it away. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1142112 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/core/StandardWrapper.java | 13 ++++++++++--- webapps/docs/changelog.xml | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/core/StandardWrapper.java b/java/org/apache/catalina/core/StandardWrapper.java index 194e2dd20..a2c85aa30 100644 --- a/java/org/apache/catalina/core/StandardWrapper.java +++ b/java/org/apache/catalina/core/StandardWrapper.java @@ -822,9 +822,16 @@ public class StandardWrapper extends ContainerBase log.debug("Allocating non-STM instance"); instance = loadServlet(); - // For non-STM, increment here to prevent a race - // condition with unload. Bug 43683, test case #3 - if (!singleThreadModel) { + if (singleThreadModel) { + // No need to lock pool since until an instance + // is created, no threads will get past this + // point + instancePool.push(instance); + nInstances++; + } else { + // For non-STM, increment here to prevent a race + // condition with unload. Bug 43683, test case + // #3 newInstance = true; countAllocated.incrementAndGet(); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 8e78c0850..8c8cdc067 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -194,6 +194,11 @@ In launcher for embedded Tomcat: do not change catalina.home system property if it had a value. (kkolinko) + + When using Servlets that implement the SingleThreadModel interface, add + the single instance created to the pool when it is determined that a + pool of servlets is required rather than throwing it away. (markt) + -- 2.11.0