Repository: logging-log4j2
Updated Branches:
  
refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure 
e0e5c1b39 -> 0bc3a8f99


LOG4J2-1447 ContextData and MutableContextData javadoc


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0bc3a8f9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0bc3a8f9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0bc3a8f9

Branch: 
refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 0bc3a8f99e3c6bc13a2037185d3cb77452470fd5
Parents: e0e5c1b
Author: rpopma <rpo...@apache.org>
Authored: Sun Aug 7 23:47:44 2016 +0900
Committer: rpopma <rpo...@apache.org>
Committed: Sun Aug 7 23:47:44 2016 +0900

----------------------------------------------------------------------
 .../apache/logging/log4j/core/ContextData.java    | 18 ++++++++++++++++++
 .../log4j/core/impl/MutableContextData.java       | 14 ++++++++++++++
 2 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0bc3a8f9/log4j-core/src/main/java/org/apache/logging/log4j/core/ContextData.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/ContextData.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/ContextData.java
index 9022d3a..9c50255 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/ContextData.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/ContextData.java
@@ -56,9 +56,18 @@ public interface ContextData extends Serializable {
     /**
      * Performs the given action for each key-value pair in this data structure
      * until all entries have been processed or the action throws an exception.
+     * <p>
+     * Some implementations may not support structural modifications (adding 
new elements or removing elements) while
+     * iterating over the contents. In such implementations, attempts to add 
or remove elements from the
+     * {@code BiConsumer}'s {@link BiConsumer#accept(Object, Object)} accept} 
method may cause a
+     * {@code ConcurrentModificationException} to be thrown.
+     * </p>
      *
      * @param action The action to be performed for each key-value pair in 
this collection
      * @param <V> type of the value
+     * @throws java.util.ConcurrentModificationException some implementations 
may not support structural modifications
+     *          to this context data while iterating over the contents with 
{@link #forEach(BiConsumer)} or
+     *          {@link #forEach(TriConsumer, Object)}.
      */
     <V> void forEach(final BiConsumer<String, ? super V> action);
 
@@ -69,12 +78,21 @@ public interface ContextData extends Serializable {
      * The third parameter lets callers pass in a stateful object to be 
modified with the key-value pairs,
      * so the TriConsumer implementation itself can be stateless and 
potentially reusable.
      * </p>
+     * <p>
+     * Some implementations may not support structural modifications (adding 
new elements or removing elements) while
+     * iterating over the contents. In such implementations, attempts to add 
or remove elements from the
+     * {@code TriConsumer}'s {@link TriConsumer#accept(Object, Object, Object) 
accept} method may cause a
+     * {@code ConcurrentModificationException} to be thrown.
+     * </p>
      *
      * @param action The action to be performed for each key-value pair in 
this collection
      * @param state the object to be passed as the third parameter to each 
invocation on the specified
      *          triconsumer
      * @param <V> type of the value
      * @param <S> type of the third parameter
+     * @throws java.util.ConcurrentModificationException some implementations 
may not support structural modifications
+     *          to this context data while iterating over the contents with 
{@link #forEach(BiConsumer)} or
+     *          {@link #forEach(TriConsumer, Object)}.
      */
     <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final 
S state);
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0bc3a8f9/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableContextData.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableContextData.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableContextData.java
index 5ed30c0..739f043 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableContextData.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableContextData.java
@@ -17,6 +17,8 @@
 package org.apache.logging.log4j.core.impl;
 
 import org.apache.logging.log4j.core.ContextData;
+import org.apache.logging.log4j.core.util.BiConsumer;
+import org.apache.logging.log4j.core.util.TriConsumer;
 
 /**
  * Exposes methods to add and remove key-value pairs to and from {@code 
ContextData}.
@@ -28,6 +30,9 @@ public interface MutableContextData extends ContextData {
 
     /**
      * Removes all key-value pairs from this collection.
+     * @throws java.util.ConcurrentModificationException some implementations 
may not support structural modifications
+     *          to this context data while iterating over the contents with 
{@link #forEach(BiConsumer)} or
+     *          {@link #forEach(TriConsumer, Object)}.
      */
     void clear();
 
@@ -36,12 +41,18 @@ public interface MutableContextData extends ContextData {
      *
      * @param key the key to add or remove. Keys may be {@code null}.
      * @param value the value to add. Values may be {@code null}.
+     * @throws java.util.ConcurrentModificationException some implementations 
may not support structural modifications
+     *          to this context data while iterating over the contents with 
{@link #forEach(BiConsumer)} or
+     *          {@link #forEach(TriConsumer, Object)}.
      */
     void putValue(final String key, final Object value);
 
     /**
      * Copy all key-value pairs from the specified {@code ContextData} into 
this {@code MutableContextData}.
      * @param source the {@code ContextData} to copy key-value pairs from
+     * @throws java.util.ConcurrentModificationException some implementations 
may not support structural modifications
+     *          to this context data while iterating over the contents with 
{@link #forEach(BiConsumer)} or
+     *          {@link #forEach(TriConsumer, Object)}.
      */
     void putAll(final ContextData source);
 
@@ -49,6 +60,9 @@ public interface MutableContextData extends ContextData {
      * Removes the key-value pair for the specified key from this context data 
collection.
      *
      * @param key the key to remove. May be {@code null}.
+     * @throws java.util.ConcurrentModificationException some implementations 
may not support structural modifications
+     *          to this context data while iterating over the contents with 
{@link #forEach(BiConsumer)} or
+     *          {@link #forEach(TriConsumer, Object)}.
      */
     void remove(final String key);
 }
\ No newline at end of file

Reply via email to