You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/03 03:37:39 UTC

[18/29] git commit: Do not assign to params for easier debugging.

Do not assign to params for easier debugging.

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

Branch: refs/heads/LOG4J2-608
Commit: 8db773208fbc9aee299138b16838763b291fa59b
Parents: 7f969fa
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue Sep 2 10:39:23 2014 -0400
Committer: Gary Gregory <ga...@gmail.com>
Committed: Tue Sep 2 10:39:23 2014 -0400

----------------------------------------------------------------------
 .../logging/log4j/streams/ByteStreamLogger.java     | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8db77320/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java
index bbc9098..6efa138 100644
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java
+++ b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java
@@ -119,17 +119,19 @@ public class ByteStreamLogger {
         }
     }
 
-    public void put(final String fqcn, final byte[] b, int off, int len) throws IOException {
-        if (len >= 0) {
+    public void put(final String fqcn, final byte[] b, final int off, final int len) throws IOException {
+        int curLen = len;
+        int curOff = off;
+        if (curLen >= 0) {
             synchronized (this.msg) {
-                while (len > this.buf.remaining()) {
+                while (curLen > this.buf.remaining()) {
                     final int remaining = this.buf.remaining();
-                    this.buf.put(b, off, remaining);
-                    len -= remaining;
-                    off += remaining;
+                    this.buf.put(b, curOff, remaining);
+                    curLen -= remaining;
+                    curOff += remaining;
                     extractMessages(fqcn);
                 }
-                this.buf.put(b, off, len);
+                this.buf.put(b, curOff, curLen);
                 extractMessages(fqcn);
             }
         } else {