[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.24-31-gb5c7149

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Wed Oct 13 23:24:03 CEST 2010


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  b5c7149857fa174693a8f21788174329afd123ab (commit)
      from  eb27832f17a90b2cb5e27631e8bcec619c573238 (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=b5c7149857fa174693a8f21788174329afd123ab
http://github.com/ceki/logback/commit/b5c7149857fa174693a8f21788174329afd123ab

commit b5c7149857fa174693a8f21788174329afd123ab
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Wed Oct 13 23:23:16 2010 +0200

    fixed LBCORE-16

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 a1916b1..84585f1 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
@@ -61,8 +61,7 @@ public class SizeAndTimeBasedFNATP<E> extends
       currentPeriodsCounter = 0;
       return;
     }
-    FileFilterUtil.reverseSortFileArrayByName(matchingFileArray);
-    currentPeriodsCounter = FileFilterUtil.extractCounter(matchingFileArray[0], stemRegex);
+    currentPeriodsCounter = FileFilterUtil.findHighestCounter(matchingFileArray, stemRegex);
     if (tbrp.getParentsRawFileProperty() != null) {
       currentPeriodsCounter++;
     }
@@ -92,8 +91,8 @@ public class SizeAndTimeBasedFNATP<E> extends
     if (((++invocationCounter) & invocationMask) != invocationMask) {
       return false;
     }
-    if (invocationMask < 0x0F)  {
-      invocationMask = (invocationMask << 1) + 1 ;
+    if (invocationMask < 0x0F) {
+      invocationMask = (invocationMask << 1) + 1;
     }
 
     if (activeFile.length() >= maxFileSize.getSize()) {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java
index 1faea62..0de8e95 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java
@@ -88,6 +88,16 @@ public class FileFilterUtil {
     return matchingFileArray;
   }
 
+  static public int findHighestCounter(File[] matchingFileArray, final String stemRegex) {
+    int max = Integer.MIN_VALUE;
+    for (File aFile : matchingFileArray) {
+      int aCounter = FileFilterUtil.extractCounter(aFile, stemRegex);
+      if (max < aCounter)
+        max = aCounter;
+    }
+    return max;
+  }
+
   static public int extractCounter(File file, final String stemRegex) {
     Pattern p = Pattern.compile(stemRegex);
     String lastFileName = file.getName();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java
new file mode 100644
index 0000000..a385d5a
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java
@@ -0,0 +1,58 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ *   or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.helpers;
+
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.rolling.helper.FileFilterUtil;
+import ch.qos.logback.core.rolling.helper.FileNamePattern;
+import org.junit.Test;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static junit.framework.Assert.assertEquals;
+
+public class FileFilterUtilTest {
+
+
+  Context context = new ContextBase();
+
+  // see also http://jira.qos.ch/browse/LBCORE-164
+  @Test
+  public void findHighestCounterTest() throws ParseException {
+    String[] sa = new String[]{"c:/log/debug-old-2010-08-10.0.log",
+            "c:/log/debug-old-2010-08-10.1.log", "c:/log/debug-old-2010-08-10.10.log",
+            "c:/log/debug-old-2010-08-10.11.log", "c:/log/debug-old-2010-08-10.12.log",
+            "c:/log/debug-old-2010-08-10.2.log", "c:/log/debug-old-2010-08-10.3.log",
+            "c:/log/debug-old-2010-08-10.4.log", "c:/log/debug-old-2010-08-10.5.log",
+            "c:/log/debug-old-2010-08-10.6.log", "c:/log/debug-old-2010-08-10.7.log",
+            "c:/log/debug-old-2010-08-10.8.log", "c:/log/debug-old-2010-08-10.9.log"};
+
+    File[] matchingFileArray = new File[sa.length];
+    for (int i = 0; i < sa.length; i++) {
+      matchingFileArray[i] = new File(sa[i]);
+    }
+    FileNamePattern fnp = new FileNamePattern("c:/log/debug-old-%d{yyyy-MM-dd}.%i.log", context);
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    String rexexp = null;
+    rexexp = fnp.toRegex(sdf.parse("2010-08-10"));
+    String stemRegex = FileFilterUtil.afterLastSlash(rexexp);
+    int result = FileFilterUtil.findHighestCounter(matchingFileArray, stemRegex);
+    assertEquals(12, result);
+  }
+}
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 f840c78..192acf5 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
@@ -13,12 +13,13 @@
  */
 package ch.qos.logback.core.helpers;
 
+import ch.qos.logback.core.util.FileUtilTest;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
- at SuiteClasses({ThrowableToStringArrayTest.class})
+ at SuiteClasses({ThrowableToStringArrayTest.class, FileUtilTest.class})
 public class PackageTest {
 
 }
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 46a126c..5e4e61e 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -46,6 +46,14 @@
     as reported by David Harrigan.
     </p>
 
+    <p>As reported in <a
+    href="http://jira.qos.ch/browse/LBCORE-164">LBCORE-164</a>,
+    <code>SizeAndTimeBasedFNATP</code> would cause previous logging
+    files with indexes over nine to be overwitten on application
+    restart. This complex bug was reported and precisely diagnosed by
+    Dieter Mueller. He has also proposed a fix which was subsequently
+    adopted as is.</p>
+
     <hr width="80%" align="center" />
 
     <h3>June 30th, 2010 - Release of version 0.9.24</h3>

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

Summary of changes:
 .../core/rolling/SizeAndTimeBasedFNATP.java        |    7 +--
 .../core/rolling/helper/FileFilterUtil.java        |   10 ++++
 .../logback/core/helpers/FileFilterUtilTest.java   |   58 ++++++++++++++++++++
 .../ch/qos/logback/core/helpers/PackageTest.java   |    3 +-
 logback-site/src/site/pages/news.html              |    8 +++
 5 files changed, 81 insertions(+), 5 deletions(-)
 create mode 100644 logback-core/src/test/java/ch/qos/logback/core/helpers/FileFilterUtilTest.java


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


More information about the logback-dev mailing list