That only seems to help in the case where you’re only manipulating local 
bindings. Keep in mind that proper thread safety here would likely entail using 
locks or modifying a class similar to ConcurrentHashMap to support hierarchical 
maps (which probably have a more computer science-like name such as B+trees or 
similar concepts). Maybe this problem requires some literature review.

> On Mar 23, 2023, at 8:41 AM, v...@apache.org wrote:
> 
> This is an automated email from the ASF dual-hosted git repository.
> 
> vy pushed a commit to branch main
> in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
> 
> 
> The following commit(s) were added to refs/heads/main by this push:
>     new 64c4bd693b Make `HierarchicalCollections` thread-safe
> 64c4bd693b is described below
> 
> commit 64c4bd693b1a1dad42f50572161b41a75933daaf
> Author: Volkan Yazıcı <vol...@yazi.ci>
> AuthorDate: Thu Mar 23 14:41:14 2023 +0100
> 
>    Make `HierarchicalCollections` thread-safe
> ---
> .../log4j/plugins/internal/util/HierarchicalCollections.java  | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git 
> a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/internal/util/HierarchicalCollections.java
>  
> b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/internal/util/HierarchicalCollections.java
> index ad47c27427..18d0093b88 100644
> --- 
> a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/internal/util/HierarchicalCollections.java
> +++ 
> b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/internal/util/HierarchicalCollections.java
> @@ -16,13 +16,8 @@
>  */
> package org.apache.logging.log4j.plugins.internal.util;
> 
> -import java.util.AbstractMap;
> -import java.util.AbstractSet;
> -import java.util.Iterator;
> -import java.util.LinkedHashMap;
> -import java.util.Map;
> -import java.util.NoSuchElementException;
> -import java.util.Set;
> +import java.util.*;
> +import java.util.concurrent.ConcurrentHashMap;
> 
> class HierarchicalCollections {
>     static <K, V> HierarchicalMap<K, V> newRootMap() {
> @@ -30,7 +25,7 @@ class HierarchicalCollections {
>     }
> 
>     private static class RootMap<K, V> extends AbstractMap<K, V> implements 
> HierarchicalMap<K, V> {
> -        private final Map<K, V> map = new LinkedHashMap<>();
> +        private final Map<K, V> map = new ConcurrentHashMap<>();
> 
>         @Override
>         public Set<Entry<K, V>> entrySet() {
> 

Reply via email to