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

rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit abee799d6bf0cce9ce2451ce6737126d60f3673d
Author: opencode <[email protected]>
AuthorDate: Wed Sep 30 10:54:55 2026 +0200

    Return a snapshot enumeration from Request.getLocales() to prevent 
ConcurrentModificationExceptions when the locales list is modified while a 
previously returned enumeration is being iterated
---
 java/org/apache/catalina/connector/Request.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 82b9583b3f..df5e9a8a8b 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1129,7 +1129,9 @@ public class Request implements HttpServletRequest {
         }
 
         if (!locales.isEmpty()) {
-            return Collections.enumeration(locales);
+            // Take a copy to prevent ConcurrentModificationExceptions if the
+            // list is modified while the enumeration is being iterated
+            return Collections.enumeration(new ArrayList<>(locales));
         }
         ArrayList<Locale> results = new ArrayList<>();
         results.add(defaultLocale);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to