Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1930

Add forEach() methods to org.apache.logging.log4j.message.MapMessage

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.0
    • Component/s: API
    • Labels:
      None

      Description

      Add forEach() methods to org.apache.logging.log4j.message.MapMessage that delegate to the internal ReadOnlyStringMap. This avoids call sites making a copy of the map by calling MapMessage.getData().

          /**
           * 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 data structure while iterating over the contents with {@link #forEach(BiConsumer)} or
           *          {@link #forEach(TriConsumer, Object)}.
           * @see ReadOnlyStringMap#forEach(BiConsumer)
           * @since 2.9
           */
          public <V> void forEach(final BiConsumer<String, ? super V> action) {
              data.forEach(action);
          }
      
          /**
           * 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>
           * 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 data structure while iterating over the contents with {@link #forEach(BiConsumer)} or
           *          {@link #forEach(TriConsumer, Object)}.
           * @see ReadOnlyStringMap#forEach(TriConsumer, Object)
           * @since 2.9
           */
          public <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final S state) {
              data.forEach(action, state);
          }
      

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1b980d8827fa0f568a515765dea7715a89bf28ff in logging-log4j2's branch refs/heads/master from Gary Gregory
        [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=1b980d8 ]

        LOG4J2-1930 Add forEach() methods to
        org.apache.logging.log4j.message.MapMessage.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1b980d8827fa0f568a515765dea7715a89bf28ff in logging-log4j2's branch refs/heads/master from Gary Gregory [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=1b980d8 ] LOG4J2-1930 Add forEach() methods to org.apache.logging.log4j.message.MapMessage.
        Hide
        garydgregory Gary Gregory added a comment -

        In Git master.

        Show
        garydgregory Gary Gregory added a comment - In Git master.

          People

          • Assignee:
            garydgregory Gary Gregory
            Reporter:
            garydgregory Gary Gregory
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development