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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 1b50903a3a Sync ContainerBase background processes with lifecycle 
operations
1b50903a3a is described below

commit 1b50903a3a841665810e90e794cf6d0d1fde6674
Author: remm <r...@apache.org>
AuthorDate: Fri Nov 17 11:35:40 2023 +0100

    Sync ContainerBase background processes with lifecycle operations
    
    Also sync check for webapp updates since the same lifecycle operations
    could cause problems.
---
 java/org/apache/catalina/core/ContainerBase.java |  2 +-
 java/org/apache/catalina/startup/HostConfig.java | 23 +++++++++++++++--------
 webapps/docs/changelog.xml                       |  8 ++++++++
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 864e3bbbe5..d3e784c413 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1074,7 +1074,7 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
      * this container. Unexpected throwables will be caught and logged.
      */
     @Override
-    public void backgroundProcess() {
+    public synchronized void backgroundProcess() {
 
         if (!getState().isAvailable()) {
             return;
diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index 141d3b3dee..b451dacfe4 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1673,15 +1673,22 @@ public class HostConfig implements LifecycleListener {
      * @param name The name of the web application to check
      */
     public void check(String name) {
-        if (tryAddServiced(name)) {
-            try {
-                DeployedApplication app = deployed.get(name);
-                if (app != null) {
-                    checkResources(app, true);
+        synchronized (host) {
+            if (host instanceof Lifecycle) {
+                if (!((Lifecycle) host).getState().isAvailable()) {
+                    return;
+                }
+            }
+            if (tryAddServiced(name)) {
+                try {
+                    DeployedApplication app = deployed.get(name);
+                    if (app != null) {
+                        checkResources(app, true);
+                    }
+                    deployApps(name);
+                } finally {
+                    removeServiced(name);
                 }
-                deployApps(name);
-            } finally {
-                removeServiced(name);
             }
         }
     }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2c8684e7d2..6a2ca0de2f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,14 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 8.5.97 (schultz)" rtext="in development">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        Background processes should not be run concurrently with lifecycle
+        oprations of a container. (remm)
+      </fix>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 8.5.96 (schultz)" rtext="Release in progres">
   <subsection name="Catalina">


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

Reply via email to