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


The following commit(s) were added to refs/heads/main by this push:
     new 65e0baa525 Restore warning to use only this listener with Server
65e0baa525 is described below

commit 65e0baa525f81a585bfb249c5db1ed3c812763f4
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 14 10:38:48 2024 +0100

    Restore warning to use only this listener with Server
---
 java/org/apache/catalina/core/AprLifecycleListener.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java 
b/java/org/apache/catalina/core/AprLifecycleListener.java
index 848eacf647..a06d9672c8 100644
--- a/java/org/apache/catalina/core/AprLifecycleListener.java
+++ b/java/org/apache/catalina/core/AprLifecycleListener.java
@@ -23,6 +23,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;
@@ -34,6 +35,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.
+ * <p>
  * Only one instance of the APR/Native library may be loaded per JVM. Loading 
multiple instances will trigger a JVM
  * crash - typically when the Connectors are destroyed. This listener utilises 
reference counting to ensure that only
  * one instance of the APR/Native library is loaded at any one time.
@@ -128,6 +131,9 @@ public class AprLifecycleListener implements 
LifecycleListener {
 
         if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
             synchronized (lock) {
+                if (!(event.getLifecycle() instanceof Server)) {
+                    log.warn(sm.getString("listener.notServer", 
event.getLifecycle().getClass().getSimpleName()));
+                }
                 if (referenceCount++ != 0) {
                     // Already loaded (note test is performed before reference 
count is incremented)
                     return;


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

Reply via email to