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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 5a8f137c2c Fix inconsistent sync
5a8f137c2c is described below

commit 5a8f137c2cc8ecb460ae57b9682d6eb8cf721827
Author: remm <r...@apache.org>
AuthorDate: Fri Sep 15 14:45:43 2023 +0200

    Fix inconsistent sync
    
    Found by coverity.
---
 java/org/apache/juli/ClassLoaderLogManager.java | 26 ++++++++++++-------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/juli/ClassLoaderLogManager.java 
b/java/org/apache/juli/ClassLoaderLogManager.java
index 14e8bb30b3..0eb11f7005 100644
--- a/java/org/apache/juli/ClassLoaderLogManager.java
+++ b/java/org/apache/juli/ClassLoaderLogManager.java
@@ -307,7 +307,7 @@ public class ClassLoaderLogManager extends LogManager {
     }
 
     @Override
-    public void reset() throws SecurityException {
+    public synchronized void reset() throws SecurityException {
         Thread thread = Thread.currentThread();
         if 
(thread.getClass().getName().startsWith("java.util.logging.LogManager$")) {
             // Ignore the call from java.util.logging.LogManager.Cleaner,
@@ -343,22 +343,20 @@ public class ClassLoaderLogManager extends LogManager {
         // method can use handlers from the parent class loaders, and closing
         // handlers that the current class loader does not own would be not
         // good.
-        synchronized (clLogInfo) {
-            for (Logger logger : clLogInfo.loggers.values()) {
-                Handler[] handlers = logger.getHandlers();
-                for (Handler handler : handlers) {
-                    logger.removeHandler(handler);
-                }
+        for (Logger logger : clLogInfo.loggers.values()) {
+            Handler[] handlers = logger.getHandlers();
+            for (Handler handler : handlers) {
+                logger.removeHandler(handler);
             }
-            for (Handler handler : clLogInfo.handlers.values()) {
-                try {
-                    handler.close();
-                } catch (Exception e) {
-                    // Ignore
-                }
+        }
+        for (Handler handler : clLogInfo.handlers.values()) {
+            try {
+                handler.close();
+            } catch (Exception e) {
+                // Ignore
             }
-            clLogInfo.handlers.clear();
         }
+        clLogInfo.handlers.clear();
     }
 
     // ------------------------------------------------------ Protected Methods


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

Reply via email to