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

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


The following commit(s) were added to refs/heads/main by this push:
     new fab59e5  Add Javadoc comment about nesting of server-wide listeners
fab59e5 is described below

commit fab59e5e07082b067060f16921c028f3d1991ae4
Author: Michael Osipov <micha...@apache.org>
AuthorDate: Mon Nov 1 09:18:47 2021 +0100

    Add Javadoc comment about nesting of server-wide listeners
---
 java/org/apache/catalina/core/AprLifecycleListener.java           | 3 +++
 .../org/apache/catalina/core/JreMemoryLeakPreventionListener.java | 3 +++
 .../apache/catalina/core/ThreadLocalLeakPreventionListener.java   | 8 ++------
 .../apache/catalina/mbeans/GlobalResourcesLifecycleListener.java  | 3 +++
 java/org/apache/catalina/security/SecurityListener.java           | 4 ++++
 java/org/apache/catalina/startup/VersionLoggerListener.java       | 4 ++++
 webapps/docs/changelog.xml                                        | 4 ++++
 7 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java 
b/java/org/apache/catalina/core/AprLifecycleListener.java
index 9ff9496..d92ac14 100644
--- a/java/org/apache/catalina/core/AprLifecycleListener.java
+++ b/java/org/apache/catalina/core/AprLifecycleListener.java
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Server;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.jni.Library;
@@ -38,6 +39,8 @@ import org.apache.tomcat.util.res.StringManager;
 /**
  * Implementation of <code>LifecycleListener</code> that will init and
  * and destroy APR.
+ * <p>
+ * This listener must only be nested within {@link Server} elements.
  *
  * @since 4.1
  */
diff --git a/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java 
b/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
index dce3cfe..47c5624 100644
--- a/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
+++ b/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
@@ -25,6 +25,7 @@ import javax.imageio.ImageIO;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Server;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.res.StringManager;
@@ -42,6 +43,8 @@ import org.apache.tomcat.util.res.StringManager;
  * Locked files usually occur when a resource inside a JAR is accessed without
  * first disabling Jar URL connection caching. The workaround is to disable 
this
  * caching by default.
+ * <p>
+ * This listener must only be nested within {@link Server} elements.
  */
 public class JreMemoryLeakPreventionListener implements LifecycleListener {
 
diff --git 
a/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java 
b/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
index f13b19a..9000576 100644
--- a/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
+++ b/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
@@ -34,19 +34,15 @@ import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.threads.ThreadPoolExecutor;
 
 /**
- * <p>
  * A {@link LifecycleListener} that triggers the renewal of threads in Executor
  * pools when a {@link Context} is being stopped to avoid thread-local related
  * memory leaks.
- * </p>
  * <p>
  * Note : active threads will be renewed one by one when they come back to the
  * pool after executing their task, see
  * {@link org.apache.tomcat.util.threads.ThreadPoolExecutor}.afterExecute().
- * </p>
- *
- * This listener must be declared in server.xml to be active.
- *
+ * <p>
+ * This listener must only be nested within {@link Server} elements.
  */
 public class ThreadLocalLeakPreventionListener extends FrameworkListener {
 
diff --git 
a/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java 
b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
index bca1ed7..d6d7506 100644
--- a/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
+++ b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
@@ -31,6 +31,7 @@ import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Role;
+import org.apache.catalina.Server;
 import org.apache.catalina.User;
 import org.apache.catalina.UserDatabase;
 import org.apache.juli.logging.Log;
@@ -42,6 +43,8 @@ import org.apache.tomcat.util.res.StringManager;
  * Implementation of <code>LifecycleListener</code> that instantiates the
  * set of MBeans associated with global JNDI resources that are subject to
  * management.
+ * <p>
+ * This listener must only be nested within {@link Server} elements.
  *
  * @author Craig R. McClanahan
  * @since 4.1
diff --git a/java/org/apache/catalina/security/SecurityListener.java 
b/java/org/apache/catalina/security/SecurityListener.java
index 782753f..cee5ae0 100644
--- a/java/org/apache/catalina/security/SecurityListener.java
+++ b/java/org/apache/catalina/security/SecurityListener.java
@@ -23,11 +23,15 @@ import java.util.Set;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Server;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.StringUtils;
 import org.apache.tomcat.util.res.StringManager;
 
+/**
+ * This listener must only be nested within {@link Server} elements.
+ */
 public class SecurityListener implements LifecycleListener {
 
     private static final Log log = LogFactory.getLog(SecurityListener.class);
diff --git a/java/org/apache/catalina/startup/VersionLoggerListener.java 
b/java/org/apache/catalina/startup/VersionLoggerListener.java
index a4f944b..6ca2ea8 100644
--- a/java/org/apache/catalina/startup/VersionLoggerListener.java
+++ b/java/org/apache/catalina/startup/VersionLoggerListener.java
@@ -25,6 +25,7 @@ import java.util.TreeMap;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Server;
 import org.apache.catalina.util.ServerInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -32,6 +33,9 @@ import org.apache.tomcat.util.res.StringManager;
 
 /**
  * Logs version information on startup.
+ * <p>
+ * This listener must only be nested within {@link Server} elements and should
+ * be the first listener defined.
  */
 public class VersionLoggerListener implements LifecycleListener {
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 896f490..0b768b4 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -143,6 +143,10 @@
         the connection. Also add missing close when running into issues
         getting the passord of a user. (remm)
       </fix>
+      <docs>
+        Add Javadoc comment which listeners must be nested whithin
+        <code>Server</code> elements only. (michaelo)
+      </docs>
     </changelog>
   </subsection>
   <subsection name="Coyote">

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

Reply via email to