You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/04/08 12:54:40 UTC

[4/5] logging-log4j2 git commit: LOG4J2-1343 synchronize on the ByteBufferDestination to protect against concurrent modification

LOG4J2-1343 synchronize on the ByteBufferDestination to protect against concurrent modification


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

Branch: refs/heads/master
Commit: 88563f2f28111901b2586c27b01be0f42d166bf0
Parents: 794af49
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 8 19:51:04 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Fri Apr 8 19:51:04 2016 +0900

----------------------------------------------------------------------
 .../apache/logging/log4j/core/appender/OutputStreamManager.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/88563f2f/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
index 34498fa..aff8573 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
@@ -205,7 +205,10 @@ public class OutputStreamManager extends AbstractManager {
      */
     protected void flushBuffer() {
         if (Constants.ENABLE_DIRECT_ENCODERS) {
-            getByteBufferDestination().drain(getByteBufferDestination().getByteBuffer());
+            final ByteBufferDestination destination = getByteBufferDestination();
+            synchronized (destination) {
+                destination.drain(destination.getByteBuffer());
+            }
         }
     }