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

remm 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 27ee036c8b Sync ContainerBase background processes with lifecycle 
operations
27ee036c8b is described below

commit 27ee036c8bea4b5e1ce3a9893158f43d391d1803
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 c654b98a6d..6e4ef4b950 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1064,7 +1064,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 5a1c62ccbe..c915734c7f 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1680,15 +1680,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 9bbfa2bcfe..e377b6efef 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 9.0.84 (remm)" 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 9.0.83 (remm)" rtext="2023-11-15">
   <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