This is an automated email from the ASF dual-hosted git repository.
remm 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 afcdd39ce2 Fix inconsistent sync
afcdd39ce2 is described below
commit afcdd39ce2b465c29821706d2a1421414888eb59
Author: remm <[email protected]>
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 701fd01168..8a4655e732 100644
--- a/java/org/apache/juli/ClassLoaderLogManager.java
+++ b/java/org/apache/juli/ClassLoaderLogManager.java
@@ -293,7 +293,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,
@@ -329,22 +329,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: [email protected]
For additional commands, e-mail: [email protected]