> On Jan 9, 2018, at 4:49, [email protected] wrote:
> 
> Repository: logging-log4j2
> Updated Branches:
>  refs/heads/master 2352052d0 -> 9637dc558
> 
> 
> [LOG4J2-2177] Replace use of deprecated Core API
> org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder.setContextMap(Map<String,
> String>). Add non-JRE-Map ctors for our not-real-Maps: StringMap and
> IndexedStringMap.
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9637dc55
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9637dc55
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9637dc55
> 
> Branch: refs/heads/master
> Commit: 9637dc558e338cf3db368dc0fc6bd2a76d09e2cf
> Parents: 2352052
> Author: Gary Gregory <[email protected]>
> Authored: Mon Jan 8 12:49:03 2018 -0700
> Committer: Gary Gregory <[email protected]>
> Committed: Mon Jan 8 12:49:03 2018 -0700
> 
> ----------------------------------------------------------------------
> .../logging/log4j/message/MapMessage.java | 21 +++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9637dc55/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
> ----------------------------------------------------------------------
> diff --git 
> a/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java 
> b/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
> index 9f2aeeb..b48e825 100644
> --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
> @@ -30,6 +30,7 @@ import org.apache.logging.log4j.util.PerformanceSensitive;
> import org.apache.logging.log4j.util.ReadOnlyStringMap;
> import org.apache.logging.log4j.util.SortedArrayStringMap;
> import org.apache.logging.log4j.util.StringBuilders;
> +import org.apache.logging.log4j.util.StringMap;
> import org.apache.logging.log4j.util.Strings;
> import org.apache.logging.log4j.util.TriConsumer;
> 
> @@ -100,6 +101,15 @@ public class MapMessage<M extends MapMessage<M, V>, V> 
> implements MultiFormatStr
>     }
> 
>     /**
> +     * Constructs a new instance based on an existing {@link 
> IndexedStringMap}.
> +     * @param map The IndexedStringMap.
> +     * @since 2.10.1
> +     */
> +    public MapMessage(final IndexedStringMap map) {
> +        this.data = map;
> +    }
> +
> +    /**
>      * Constructs a new instance.
>      * 
>      * @param  initialCapacity the initial capacity.
> @@ -109,13 +119,22 @@ public class MapMessage<M extends MapMessage<M, V>, V> 
> implements MultiFormatStr
>     }
> 
>     /**
> -     * Constructs a new instance based on an existing Map.
> +     * Constructs a new instance based on an existing {@link Map}.
>      * @param map The Map.
>      */
>     public MapMessage(final Map<String, V> map) {
>         this.data = new SortedArrayStringMap(map);
>     }
> 
> +    /**
> +     * Constructs a new instance based on an existing {@link StringMap}.
> +     * @param map The StringMap.
> +     * @since 2.10.1
> +     */
> +    public MapMessage(final StringMap map) {
> +        this.data = map instanceof IndexedStringMap ? (IndexedStringMap) map 
> : new SortedArrayStringMap(map);
> +    }
> +

The constructor should make a defensive copy of the constructor parameter 
regardless of whether it implements IndexedStringMap or not. 


>     @Override
>     public String[] getFormats() {
>         return MapFormat.names();
> 

Reply via email to