[logback-dev] branch, master, updated. a60e0ea2bd6b90220df2f0d9d5296ca3a25d1cca

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Sun Nov 29 00:02:23 CET 2009


The branch, master has been updated
       via  a60e0ea2bd6b90220df2f0d9d5296ca3a25d1cca (commit)
      from  0908ef4dc8bebd0c8f38dbdd4c2d0282a01d77fb (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=a60e0ea2bd6b90220df2f0d9d5296ca3a25d1cca
http://github.com/ceki/logback/commit/a60e0ea2bd6b90220df2f0d9d5296ca3a25d1cca

commit a60e0ea2bd6b90220df2f0d9d5296ca3a25d1cca
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Sat Nov 28 23:58:39 2009 +0100

    - fixed race condition by having the test wait for the compresison
    thread at least once before the next rollover occurs
    
    This is OK, since in production, the rollver period is much much
    longer than the time it takes to do compression. In our tests however,
    this reation does not hold.

diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java
index d152d6d..02cc66a 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP.java
@@ -36,6 +36,7 @@ public class SizeAndTimeBasedFNATP<E> extends
     super.start();
 
     archiveRemover = new SizeAndTimeBasedArchiveRemover(tbrp.fileNamePattern, rc);
+    archiveRemover.setContext(context);
     
     // we need to get the correct value of currentPeriodsCounter.
     // usually the value is 0, unless the appender or the application
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
index 2d3dcd4..1387f12 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
@@ -22,7 +22,9 @@ import java.util.Calendar;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -110,7 +112,6 @@ public class TimeBasedRollingWithArchiveRemovalTest {
         + "}/clean.txt.zip", MILLIS_IN_MONTH, maxHistory, numPeriods);
     int beginPeriod = Calendar.getInstance().get(Calendar.MONTH);
     boolean extraFolder = extraFolder(numPeriods, 12, beginPeriod, maxHistory);
-    StatusPrinter.print(context);
     check(expectedCountWithFolders(2, extraFolder));
   }
 
@@ -145,9 +146,10 @@ public class TimeBasedRollingWithArchiveRemovalTest {
     doRollover(
         randomOutputDir + "/%d{" + DAILY_DATE_PATTERN + "}-clean.%i.zip",
         MILLIS_IN_DAY, 5, 5 * 4);
-    
+
     // make .zip optional so that if for one reason or another, no size-based
-    // rollover occurs on the last period, that the last period is still accounted
+    // rollover occurs on the last period, that the last period is still
+    // accounted
     // for
     checkPatternCompliance(5 + 1 + slashCount,
         "\\d{4}-\\d{2}-\\d{2}-clean(\\.\\d)(.zip)?");
@@ -198,12 +200,22 @@ public class TimeBasedRollingWithArchiveRemovalTest {
       tbrp.timeBasedTriggering.setCurrentTime(addTime(tbrp.timeBasedTriggering
           .getCurrentTime(), periodDurationInMillis / ticksPerPeriod));
 
+      // wait every now and then for the compression job
+      // otherwise, we might rollover a file for a given period before a previous
+      // period's compressor had a chance to run
+      if(i % (ticksPerPeriod/2) == 0) {
+        waitForCompression(tbrp);
+      }
     }
-    
+    waitForCompression(tbrp);
+    rfa.stop();
+  }
+
+  void waitForCompression(TimeBasedRollingPolicy<Object> tbrp)
+      throws InterruptedException, ExecutionException, TimeoutException {
     if (tbrp.future != null && !tbrp.future.isDone()) {
       tbrp.future.get(200, TimeUnit.MILLISECONDS);
     }
-    rfa.stop();
   }
 
   void findAllFoldersRecursively(File dir, List<File> fileList) {
@@ -281,7 +293,7 @@ public class TimeBasedRollingWithArchiveRemovalTest {
   // year is 2012, and not 2013 (the current year).
   boolean extraFolder(int numPeriods, int periodsPerEra, int beginPeriod,
       int maxHistory) {
-	int adjustedBegin =   beginPeriod+1;
+    int adjustedBegin = beginPeriod + 1;
     int remainder = ((adjustedBegin) + numPeriods) % periodsPerEra;
     return (remainder < maxHistory + 1);
   }

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

Summary of changes:
 .../core/rolling/SizeAndTimeBasedFNATP.java        |    1 +
 .../TimeBasedRollingWithArchiveRemovalTest.java    |   24 +++++++++++++++-----
 2 files changed, 19 insertions(+), 6 deletions(-)


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


More information about the logback-dev mailing list