Ensure that calls to StandardWrapper methods() that may trigger creation of a Servlet...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 31 Jul 2011 19:34:14 +0000 (19:34 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 31 Jul 2011 19:34:14 +0000 (19:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1152621 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardWrapper.java
webapps/docs/changelog.xml

index 2c154d6..e5023cf 100644 (file)
@@ -566,8 +566,18 @@ public class StandardWrapper extends ContainerBase
      */
     public boolean isSingleThreadModel() {
 
+        // Short-cuts
+        // If singleThreadModel is true, must have already checked this
+        // If instance != null, must have already loaded 
+        if (singleThreadModel || instance != null) {
+            return singleThreadModel;
+        }
+        
+        // The logic to determine this safely is more complex than one might
+        // expect. allocate() already has the necessary logic so re-use it.
         try {
-            loadServlet();
+            Servlet s = allocate();
+            deallocate(s);
         } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
         }
@@ -608,7 +618,9 @@ public class StandardWrapper extends ContainerBase
     @Override
     public String[] getServletMethods() throws ServletException {
 
-        Class<? extends Servlet> servletClazz = loadServlet().getClass();
+        instance = loadServlet();
+        
+        Class<? extends Servlet> servletClazz = instance.getClass();
         if (!javax.servlet.http.HttpServlet.class.isAssignableFrom(
                                                         servletClazz)) {
             return DEFAULT_SERVLET_METHODS;
index 2a99a4b..e87b7a1 100644 (file)
         <bug>51588</bug>: Make it easier to extend the AccessLogValve to add
         support for custom elements. (markt)
       </fix>
+      <fix>
+        Ensure that calls to StandardWrapper methods() that may trigger creation
+        of a Servlet instance always do so in way that correctly instantiates a
+        Servlet instance. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">