[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-71-g26a0a37

Gitbot git-noreply at pixie.qos.ch
Tue Mar 6 18:02:41 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  26a0a37ccb1107094b079154e1a2d0f8c41eb9b6 (commit)
      from  bfe8b7f3b44493325020de0d6b852a38be9b4053 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=26a0a37ccb1107094b079154e1a2d0f8c41eb9b6
http://github.com/ceki/logback/commit/26a0a37ccb1107094b079154e1a2d0f8c41eb9b6

commit 26a0a37ccb1107094b079154e1a2d0f8c41eb9b6
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Mar 6 17:59:32 2012 +0100

    Fix LBCLASSIC-221

diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
index cc20e17..fe0a6ba 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
@@ -272,13 +272,13 @@ public class SMTPAppender_GreenTest {
     smtpAppender.setLayout(buildPatternLayout(lc));
     smtpAppender.start();
     logger.addAppender(smtpAppender);
-    String h1 = "hello one";
-    logger.debug(h1);
-    logger.error("error one");
+    String msg0 = "hello zero";
+    logger.debug(msg0);
+    logger.error("error zero");
 
-    String h2 = "hello two";
-    logger.debug(h2);
-    logger.error("error two");
+    String msg1 = "hello one";
+    logger.debug(msg1);
+    logger.error("error one");
 
     waitUntilEmailIsSent();
 
@@ -290,12 +290,14 @@ public class SMTPAppender_GreenTest {
     MimeMultipart content0 = (MimeMultipart) mm0.getContent();
     String body0 = GreenMailUtil.getBody(content0.getBodyPart(0));
     System.out.println(body0);
+    System.out.println("--------------");
 
     MimeMessage mm1 = mma[1];
     MimeMultipart content1 = (MimeMultipart) mm1.getContent();
     String body1 = GreenMailUtil.getBody(content1.getBodyPart(0));
-    assertFalse(body1.contains(h1));
     System.out.println(body1);
+    // second body should not contain content from first message
+    assertFalse(body1.contains(msg0));
 
 
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index 494afdb..fe57c1b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -184,8 +184,13 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
 
     try {
       if (eventEvaluator.evaluate(eventObject)) {
+        // clone the CyclicBuffer before sending out asynchronously
+        CyclicBuffer<E> cbClone = new CyclicBuffer<E>(cb);
+        // see http://jira.qos.ch/browse/LBCLASSIC-221
+        cb.clear();
+
         // perform actual sending asynchronously
-        SenderRunnable senderRunnable = new SenderRunnable(new CyclicBuffer<E>(cb), eventObject);
+        SenderRunnable senderRunnable = new SenderRunnable(cbClone, eventObject);
         context.getExecutorService().execute(senderRunnable);
       }
     } catch (EvaluationException ex) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java
new file mode 100644
index 0000000..e4fd7f4
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java
@@ -0,0 +1,48 @@
+package ch.qos.logback.core.helpers;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class CyclicBufferTest {
+
+
+  void assertSize(CyclicBuffer<String> cb, int size) {
+     assertEquals(size, cb.length());
+  }
+  @Test
+  public void smoke() {
+    CyclicBuffer<String> cb = new CyclicBuffer<String>(2);
+    assertSize(cb, 0);
+    cb.add("zero");
+    assertSize(cb, 1);
+    cb.add("one");
+    assertSize(cb, 2);
+    cb.add("two");
+    assertSize(cb, 2);
+    assertEquals("one", cb.get());
+    assertSize(cb, 1);
+    assertEquals("two",cb.get());
+    assertSize(cb, 0);
+  }
+
+
+  @Test
+  public void cloning() {
+    CyclicBuffer<String> cb = new CyclicBuffer<String>(2);
+    cb.add("zero");
+    cb.add("one");
+
+    CyclicBuffer<String> clone = new CyclicBuffer<String>(cb);
+    assertSize(clone, 2);
+    cb.clear();
+    assertSize(cb, 0);
+
+    List<String> witness = Arrays.asList("zero", "one");
+    assertEquals(witness, clone.asList());
+
+  }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java
index ab2e639..053db92 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/PackageTest.java
@@ -19,7 +19,7 @@ import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
- at SuiteClasses({ThrowableToStringArrayTest.class, FileUtilTest.class})
+ at SuiteClasses({ThrowableToStringArrayTest.class, FileUtilTest.class, CyclicBufferTest.class})
 public class PackageTest {
 
 }
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 5e654c8..0a6ba3f 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -54,6 +54,12 @@
     href="http://jira.qos.ch/browse/LBCLASSIC-276">LBCLASSIC-276</a>.
     </p>
 
+    <p><code>SMTPAppender</code> clears the relevant cyclic buffer
+    before asynchronous transmission. This corrects <a
+    href="http://jira.qos.ch/browse/LBCLASSIC-221">LBCLASSIC-221</a>
+    as reported by Chris Cheshire.
+    </p>
+
     <p><code>RequestLogImpl</code> can now lookup for the
     logback-access configuration file as a class path resource. This
     feature was requested in <a

-----------------------------------------------------------------------

Summary of changes:
 .../classic/net/SMTPAppender_GreenTest.java        |   16 ++++---
 .../ch/qos/logback/core/net/SMTPAppenderBase.java  |    7 +++-
 .../qos/logback/core/helpers/CyclicBufferTest.java |   48 ++++++++++++++++++++
 .../ch/qos/logback/core/helpers/PackageTest.java   |    2 +-
 logback-site/src/site/pages/news.html              |    6 +++
 5 files changed, 70 insertions(+), 9 deletions(-)
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/helpers/CyclicBufferTest.java


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list