You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/09/22 13:21:32 UTC

[tomcat] 04/05: Remove more STM references

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 8dc018ffe0cdc8c7352a41dd24ddb5d072c3a6df
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Sep 21 12:50:18 2021 +0100

    Remove more STM references
---
 java/org/apache/catalina/Container.java                 |  4 +---
 java/org/apache/catalina/Wrapper.java                   | 15 ++++-----------
 java/org/apache/catalina/core/StandardWrapper.java      | 11 +++--------
 java/org/apache/catalina/core/StandardWrapperValve.java |  2 +-
 java/org/apache/catalina/core/mbeans-descriptors.xml    |  9 ---------
 res/findbugs/filter-false-positives.xml                 |  6 ------
 6 files changed, 9 insertions(+), 38 deletions(-)

diff --git a/java/org/apache/catalina/Container.java b/java/org/apache/catalina/Container.java
index 98dd2be..0881a70 100644
--- a/java/org/apache/catalina/Container.java
+++ b/java/org/apache/catalina/Container.java
@@ -43,9 +43,7 @@ import org.apache.juli.logging.Log;
  *     of Contexts.
  * <li><b>Context</b> - Representation of a single ServletContext, which will
  *     typically contain one or more Wrappers for the supported servlets.
- * <li><b>Wrapper</b> - Representation of an individual servlet definition
- *     (which may support multiple servlet instances if the servlet itself
- *     implements SingleThreadModel).
+ * <li><b>Wrapper</b> - Representation of an individual servlet definition.
  * </ul>
  * A given deployment of Catalina need not include Containers at all of the
  * levels described above.  For example, an administration application
diff --git a/java/org/apache/catalina/Wrapper.java b/java/org/apache/catalina/Wrapper.java
index 160e6f6..b40252e 100644
--- a/java/org/apache/catalina/Wrapper.java
+++ b/java/org/apache/catalina/Wrapper.java
@@ -31,8 +31,7 @@ import jakarta.servlet.UnavailableException;
  * <p>
  * Implementations of Wrapper are responsible for managing the servlet life
  * cycle for their underlying servlet class, including calling init() and
- * destroy() at appropriate times, as well as respecting the existence of
- * the SingleThreadModel declaration on the servlet class itself.
+ * destroy() at appropriate times.
  * <p>
  * The parent Container attached to a Wrapper will generally be an
  * implementation of Context, representing the servlet context (and
@@ -190,12 +189,8 @@ public interface Wrapper extends Container {
 
     /**
      * Allocate an initialized instance of this Servlet that is ready to have
-     * its <code>service()</code> method called.  If the Servlet class does
-     * not implement <code>SingleThreadModel</code>, the (only) initialized
-     * instance may be returned immediately.  If the Servlet class implements
-     * <code>SingleThreadModel</code>, the Wrapper implementation must ensure
-     * that this instance is not allocated again until it is deallocated by a
-     * call to <code>deallocate()</code>.
+     * its <code>service()</code> method called.  The previously initialized
+     * instance may be returned immediately.
      *
      * @exception ServletException if the Servlet init() method threw
      *  an exception
@@ -206,9 +201,7 @@ public interface Wrapper extends Container {
 
 
     /**
-     * Return this previously allocated servlet to the pool of available
-     * instances.  If this servlet class does not implement SingleThreadModel,
-     * no action is actually required.
+     * Decrement the allocation count for the servlet instance.
      *
      * @param servlet The servlet to be returned
      *
diff --git a/java/org/apache/catalina/core/StandardWrapper.java b/java/org/apache/catalina/core/StandardWrapper.java
index 83599ae..22aef41 100644
--- a/java/org/apache/catalina/core/StandardWrapper.java
+++ b/java/org/apache/catalina/core/StandardWrapper.java
@@ -110,8 +110,7 @@ public class StandardWrapper extends ContainerBase
     protected final NotificationBroadcasterSupport broadcaster;
 
     /**
-     * The count of allocations that are currently active (even if they
-     * are for the same instance, as will be true on a non-STM servlet).
+     * The count of allocations that are currently active.
      */
     protected final AtomicInteger countAllocated = new AtomicInteger(0);
 
@@ -679,11 +678,8 @@ public class StandardWrapper extends ContainerBase
                 if (instance == null) {
                     try {
                         if (log.isDebugEnabled()) {
-                            log.debug("Allocating non-STM instance");
+                            log.debug("Allocating instance");
                         }
-
-                        // Note: We don't know if the Servlet implements
-                        // SingleThreadModel until we have loaded it.
                         instance = loadServlet();
                         newInstance = true;
                         // Increment here to prevent a race condition
@@ -703,7 +699,7 @@ public class StandardWrapper extends ContainerBase
         }
 
         if (log.isTraceEnabled()) {
-            log.trace("  Returning non-STM instance");
+            log.trace("  Returning instance");
         }
         // For new instances, count will have been incremented at the
         // time of creation
@@ -1123,7 +1119,6 @@ public class StandardWrapper extends ContainerBase
         unloading = true;
 
         // Loaf a while if the current instance is allocated
-        // (possibly more than once if non-STM)
         if (countAllocated.get() > 0) {
             int nRetries = 0;
             long delay = unloadDelay / 20;
diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java b/java/org/apache/catalina/core/StandardWrapperValve.java
index bc7e067..f8061d6 100644
--- a/java/org/apache/catalina/core/StandardWrapperValve.java
+++ b/java/org/apache/catalina/core/StandardWrapperValve.java
@@ -75,7 +75,7 @@ final class StandardWrapperValve extends ValveBase {
 
     /**
      * Invoke the servlet we are managing, respecting the rules regarding
-     * servlet lifecycle and SingleThreadModel support.
+     * servlet lifecycle support.
      *
      * @param request Request to be processed
      * @param response Response to be produced
diff --git a/java/org/apache/catalina/core/mbeans-descriptors.xml b/java/org/apache/catalina/core/mbeans-descriptors.xml
index 45af1f9..db0d6ca 100644
--- a/java/org/apache/catalina/core/mbeans-descriptors.xml
+++ b/java/org/apache/catalina/core/mbeans-descriptors.xml
@@ -1574,11 +1574,6 @@
                type="int"
                writeable="false" />
 
-    <attribute name="countAllocated"
-               description="The count of allocations that are currently active (even if they  are for the same instance, as will be true on a non-STM servlet)."
-               type="int"
-               writeable="false" />
-
     <attribute name="errorCount"
                description="Error count"
                type="int"
@@ -1598,10 +1593,6 @@
                type="long"
                writeable="false" />
 
-    <attribute name="maxInstances"
-               description="Maximum number of STM instances."
-               type="int" />
-
     <attribute name="minTime"
                description="Minimum processing time of a request"
                type="long"
diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml
index 168e9c6..579dbce 100644
--- a/res/findbugs/filter-false-positives.xml
+++ b/res/findbugs/filter-false-positives.xml
@@ -244,12 +244,6 @@
     <Bug code="SWL" />
   </Match>
   <Match>
-    <!-- null return value is documented -->
-    <Class name="org.apache.catalina.core.StandardWrapper" />
-    <Method name="isSingleThreadModel" />
-    <Bug pattern="NP_BOOLEAN_RETURN_NULL" />
-  </Match>
-  <Match>
     <!-- The code is adding HTTP request headers, not parameters and the
          header parsing on input will have removed any CR or LF characters. -->
     <Class name="org.apache.catalina.filters.CorsFilter" />

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