Log4j 2
  1. Log4j 2
  2. LOG4J2-311

FastFileAppender and FastRollingFileAppender not thread-safe

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta8
    • Fix Version/s: 2.0-beta9
    • Component/s: Appenders, Core
    • Labels:
      None

      Description

      FastFileManager#flush method needs to be synchronized.

      I'm seeing the exception below. This can only happen if two threads modify the ByteBuffer simultaneously.

      2013-07-17 19:00:29,033 ERROR An exception occurred processing Appender LatencyFile java.lang.IllegalArgumentException
      	at java.nio.Buffer.position(Buffer.java:236)
      	at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:185)
      	at org.apache.logging.log4j.core.appender.FastFileManager.write(FastFileManager.java:96)
      	at org.apache.logging.log4j.core.appender.OutputStreamManager.write(OutputStreamManager.java:129)
      	at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:115)
      	at org.apache.logging.log4j.core.appender.FastFileAppender.append(FastFileAppender.java:87)
      	at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:102)
      	at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:426)
      	at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:407)
      	at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:368)
      	at org.apache.logging.log4j.core.Logger.log(Logger.java:110)
      	at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:1011)
      	at ...
      

        Activity

        Hide
        Remko Popma added a comment -

        Fixed in revision 1504297:

        Made close() and flush() methods synchronized in
        FastFileManager, FastRollingFileManager and OutputStreamManager.

        Show
        Remko Popma added a comment - Fixed in revision 1504297: Made close() and flush() methods synchronized in FastFileManager, FastRollingFileManager and OutputStreamManager.

          People

          • Assignee:
            Remko Popma
            Reporter:
            Remko Popma
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development