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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 53c368b14e Restore warning to use only this listener with Server
53c368b14e is described below

commit 53c368b14e047921ffa1775e9abb253588466bf0
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 112b458f5a..f65c040d07 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