Repository: logging-log4j2
Updated Branches:
  refs/heads/master 272ca7e77 -> f56b284a5


[LOG4J2-1071] Allow for bufferSize=0 in SMTP appender. Apply patch with
minor formatting changes.

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

Branch: refs/heads/master
Commit: f56b284a54d9fcb7c0c2c1ed9ec8bca1d9f5b93e
Parents: 272ca7e
Author: Ben Ludkiewicz <ben.ludkiew...@londen-insurance.com>
Authored: Fri Jul 28 15:15:01 2017 -0700
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Fri Jul 28 15:15:01 2017 -0700

----------------------------------------------------------------------
 .../logging/log4j/core/util/CyclicBuffer.java   | 22 +++++++++++---------
 src/changes/changes.xml                         |  3 +++
 2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f56b284a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CyclicBuffer.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CyclicBuffer.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CyclicBuffer.java
index 0edc65e..d603b8b 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CyclicBuffer.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/CyclicBuffer.java
@@ -37,8 +37,8 @@ public final class CyclicBuffer<T> {
      * @throws IllegalArgumentException if the size is negative.
      */
     public CyclicBuffer(final Class<T> clazz, final int size) throws 
IllegalArgumentException {
-        if (size < 1) {
-            throw new IllegalArgumentException("The maxSize argument (" + size 
+ ") is not a positive integer.");
+        if (size < 0) {
+            throw new IllegalArgumentException("The maxSize argument (" + size 
+ ") cannot be negative.");
         }
         this.ring = makeArray(clazz, size);
         this.clazz = clazz;
@@ -54,15 +54,17 @@ public final class CyclicBuffer<T> {
      * @param item The item to add to the buffer.
      */
     public synchronized void add(final T item) {
-        ring[last] = item;
-        if (++last == ring.length) {
-            last = 0;
-        }
+        if (ring.length > 0) {
+            ring[last] = item;
+            if (++last == ring.length) {
+                last = 0;
+            }
 
-        if (numElems < ring.length) {
-            numElems++;
-        } else if (++first == ring.length) {
-            first = 0;
+            if (numElems < ring.length) {
+                numElems++;
+            } else if (++first == ring.length) {
+                first = 0;
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f56b284a/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8cf1d43..5994595 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -37,6 +37,9 @@
       <action issue="LOG4J2-1984" dev="rgoers" type="update">
         Allow maxLength of StructuredData to be specified by the user.
       </action>
+      <action issue="LOG4J2-1071" dev="ggregory" type="update" due-to="Ben 
Ludkiewicz, Benjamin Jaton">
+        Allow for bufferSize=0 in SMTP appender.
+      </action>
       <action issue="LOG4J2-1981" dev="mikes" type="add">
         JsonLayout, XmlLayout and YamlLayout support 0-byte termination of log 
events.
       </action>

Reply via email to