Author: markt
Date: Thu Jul 14 19:58:48 2016
New Revision: 1752737

URL: http://svn.apache.org/viewvc?rev=1752737&view=rev
Log:
Fix problem with JMX triggered parallel application init reported on users list

Modified:
    tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
    tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=1752737&r1=1752736&r2=1752737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java Thu Jul 14 
19:58:48 2016
@@ -521,33 +521,22 @@ public class StandardWrapper extends Con
 
 
     /**
-     * @return <code>true</code> if the servlet class represented by this
-     * component implements the <code>SingleThreadModel</code> interface.
+     * Does the servlet class represented by this component implement the
+     * <code>SingleThreadModel</code> interface? This can only be determined
+     * once the class is loaded. Calling this method will not trigger loading
+     * the class since that may cause the application to behave unexpectedly.
+     *
+     * @return {@code null} if the class has not been loaded, otherwise {@code
+     *         true} if the servlet does implement {@code SingleThreadModel} 
and
+     *         {@code false} if it does not.
      */
-    public boolean isSingleThreadModel() {
-
-        // Short-cuts
-        // If singleThreadModel is true, must have already checked this
-        // If instance != null, must have already loaded
+    public Boolean isSingleThreadModel() {
+        // If the servlet has been loaded either singleThreadModel will be true
+        // or instance will be non-null
         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.
-        // Make sure the Servlet is loaded with the right class loader
-        ClassLoader oldCL = null;
-        try {
-            oldCL = ((Context) getParent()).bind(false, null);
-            Servlet s = allocate();
-            deallocate(s);
-        } catch (Throwable t) {
-            ExceptionUtils.handleThrowable(t);
-        } finally {
-            ((Context) getParent()).unbind(false, oldCL);
+            return Boolean.valueOf(singleThreadModel);
         }
-        return singleThreadModel;
-
+        return null;
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml?rev=1752737&r1=1752736&r2=1752737&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml Thu Jul 
14 19:58:48 2016
@@ -1609,7 +1609,7 @@
 
     <attribute name="singleThreadModel"
                description="Does this servlet implement the SingleThreadModel 
interface?"
-               type="boolean"
+               type="java.lang.Boolean"
                is="true"
                writeable="false" />
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1752737&r1=1752736&r2=1752737&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Jul 14 19:58:48 2016
@@ -51,6 +51,13 @@
         <bug>59813</bug>: Ensure that circular relations of the Class-Path
         attribute from JAR manifests will be processed correctly. (violetagg)
       </fix>
+      <fix>
+        Ensure that reading the <code>singleThreadModel</code> attribute of a
+        <code>StandardWrapper</code> via JMX does not trigger initialisation of
+        the associated servlet. With some frameworks this can trigger an
+        unexpected initialisation thread and if initilisation is not 
thread-safe
+        the initialisation can then fail. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to