Author: remy.maucherat(a)jboss.com
Date: 2008-07-03 10:14:44 -0400 (Thu, 03 Jul 2008)
New Revision: 696
Modified:
trunk/java/org/apache/catalina/core/StandardWrapper.java
Log:
- Port latest patch to cleanup possible problems when a reload is going on.
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2008-07-02 12:35:10 UTC (rev
695)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2008-07-03 14:14:44 UTC (rev
696)
@@ -763,6 +763,8 @@
throw new ServletException
(sm.getString("standardWrapper.unloading", getName()));
+ boolean newInstance = false;
+
// If not SingleThreadedModel, return the same instance every time
if (!singleThreadModel) {
@@ -775,6 +777,12 @@
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) {
+ newInstance = true;
+ countAllocated++;
+ }
} catch (ServletException e) {
throw e;
} catch (Throwable e) {
@@ -788,6 +796,11 @@
if (!singleThreadModel) {
if (log.isTraceEnabled())
log.trace(" Returning non-STM instance");
+ // For new instances, count will have been incremented at the
+ // time of creation
+ if (!newInstance) {
+ countAllocated++;
+ }
return (instance);
}
Show replies by date