Log4j 2
  1. Log4j 2
  2. LOG4J2-296

Wasted work in FlumePersistentManager.createManager

    Details

      Description

      The problem appears in Log4j 2.0-beta7 and in revision 1497930. I
      attached a one-line patch that fixes it.

      In method "FlumePersistentManager.createManager", the loop over
      "properties.entrySet()" should break immediately after "key" is set
      the first time to "entry.getValue()". I don't think "key" is set a
      second time (and therefore all future iterations are not useful), but
      if it is, then there is a problem in the implementation: when the loop
      exits, "key" would be set to the last value of "entry.getValue()" that
      meets some condition; however "properties.entrySet()" is a Set and
      therefore the order of iterating it is non-deterministic, i.e., the
      implementation should not rely on which the "last value" is.

      1. patch.diff
        0.7 kB
        Adrian Nistor

        Activity

        Adrian Nistor created issue -
        Adrian Nistor made changes -
        Field Original Value New Value
        Attachment patch.diff [ 12590096 ]
        Gary Gregory made changes -
        Summary Wasted work in BDBManagerFactory.createManager Wasted work in FlumePersistentManager.createManager
        Gary Gregory made changes -
        Description The problem appears in Log4j 2.0-beta7 and in revision 1497930. I
        attached a one-line patch that fixes it.

        In method "BDBManagerFactory.createManager", the loop over
        "properties.entrySet()" should break immediately after "key" is set
        the first time to "entry.getValue()". I don't think "key" is set a
        second time (and therefore all future iterations are not useful), but
        if it is, then there is a problem in the implementation: when the loop
        exits, "key" would be set to the last value of "entry.getValue()" that
        meets some condition; however "properties.entrySet()" is a Set and
        therefore the order of iterating it is non-deterministic, i.e., the
        implementation should not rely on which the "last value" is.
        The problem appears in Log4j 2.0-beta7 and in revision 1497930. I
        attached a one-line patch that fixes it.

        In method "FlumePersistentManager.createManager", the loop over
        "properties.entrySet()" should break immediately after "key" is set
        the first time to "entry.getValue()". I don't think "key" is set a
        second time (and therefore all future iterations are not useful), but
        if it is, then there is a problem in the implementation: when the loop
        exits, "key" would be set to the last value of "entry.getValue()" that
        meets some condition; however "properties.entrySet()" is a Set and
        therefore the order of iterating it is non-deterministic, i.e., the
        implementation should not rely on which the "last value" is.
        Hide
        Gary Gregory added a comment -

        Thank you for the patch.

        commit -m "[LOG4J2-296] Wasted work in FlumePersistentManager.createManager." C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml C:/vcs/svn/apache/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
            Sending        C:/vcs/svn/apache/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
            Sending        C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml
            Transmitting file data ...
            Committed revision 1498789.
        
        Show
        Gary Gregory added a comment - Thank you for the patch. commit -m "[LOG4J2-296] Wasted work in FlumePersistentManager.createManager." C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml C:/vcs/svn/apache/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java Sending C:/vcs/svn/apache/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java Sending C:/vcs/svn/apache/log4j2/trunk/src/changes/changes.xml Transmitting file data ... Committed revision 1498789.
        Gary Gregory made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Gary Gregory [ garydgregory ]
        Fix Version/s 2.0-beta8 [ 12324575 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        3d 7h 56m 1 Gary Gregory 02/Jul/13 06:47

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development