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 2014/09/18 18:24:57 UTC
[10/17] git commit: LOG4J2-431 small fix to prevent spurious
buffer.force() calls
LOG4J2-431 small fix to prevent spurious buffer.force() calls
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/63aed83d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/63aed83d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/63aed83d
Branch: refs/heads/master
Commit: 63aed83d6abb149935954370341f4d0beab85440
Parents: a5325b3
Author: rpopma <rp...@apache.org>
Authored: Thu Sep 18 00:44:47 2014 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Sep 18 00:44:47 2014 +0900
----------------------------------------------------------------------
.../log4j/core/appender/MemoryMappedFileManager.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/63aed83d/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java
index 29f8c54..04d4ef1 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java
@@ -111,9 +111,8 @@ public class MemoryMappedFileManager extends OutputStreamManager {
}
mappedBuffer.put(bytes, offset, length);
- if (isForce) {
- flush();
- }
+ // no need to call flush() if force is true,
+ // already done in AbstractOutputStreamAppender.append
}
private synchronized void remap() {
@@ -205,6 +204,15 @@ public class MemoryMappedFileManager extends OutputStreamManager {
public int getRegionLength() {
return regionLength;
}
+
+ /**
+ * Returns {@code true} if the content of the buffer should be forced to the storage device on every write,
+ * {@code false} otherwise.
+ * @return whether each write should be force-sync'ed
+ */
+ public boolean isImmediateFlush() {
+ return isForce;
+ }
/** {@code OutputStream} subclass that does not write anything. */
static class DummyOutputStream extends OutputStream {