This is an automated email from the ASF dual-hosted git repository.
markt 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 8a5adbca61 Ensure access to children is always sync'd - identified by
Coverity
8a5adbca61 is described below
commit 8a5adbca614a5a5bb56d67633da03d186a775e74
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Aug 10 14:08:30 2023 +0100
Ensure access to children is always sync'd - identified by Coverity
---
java/org/apache/catalina/core/ContainerBase.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/catalina/core/ContainerBase.java
b/java/org/apache/catalina/core/ContainerBase.java
index d7fa461628..7e4c1fe550 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1163,11 +1163,15 @@ public abstract class ContainerBase extends
LifecycleMBeanBase implements Contai
return keyProperties.toString();
}
+
public ObjectName[] getChildren() {
- List<ObjectName> names = new ArrayList<>(children.size());
- for (Container next : children.values()) {
- if (next instanceof ContainerBase) {
- names.add(next.getObjectName());
+ List<ObjectName> names;
+ synchronized (children) {
+ names = new ArrayList<>(children.size());
+ for (Container next : children.values()) {
+ if (next instanceof ContainerBase) {
+ names.add(next.getObjectName());
+ }
}
}
return names.toArray(new ObjectName[0]);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]