logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1566378 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
Date Sun, 09 Feb 2014 19:50:23 GMT
Author: ggregory
Date: Sun Feb  9 19:50:23 2014
New Revision: 1566378

URL: http://svn.apache.org/r1566378
Log:
Replace duplicate magic strings with constants.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java?rev=1566378&r1=1566377&r2=1566378&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
Sun Feb  9 19:50:23 2014
@@ -76,6 +76,10 @@ import org.apache.logging.log4j.status.S
  */
 @Plugin(name = "DefaultRolloverStrategy", category = "Core", printObject = true)
 public class DefaultRolloverStrategy implements RolloverStrategy {
+    
+    private static final String EXT_ZIP = ".zip";
+    private static final String EXT_GZIP = ".gz";
+
     /**
      * Allow subclasses access to the status logger without creating another instance.
      */
@@ -185,9 +189,9 @@ public class DefaultRolloverStrategy imp
 
         String highFilename = subst.replace(buf);
 
-        if (highFilename.endsWith(".gz")) {
+        if (highFilename.endsWith(EXT_GZIP)) {
             suffixLength = 3;
-        } else if (highFilename.endsWith(".zip")) {
+        } else if (highFilename.endsWith(EXT_ZIP)) {
             suffixLength = 4;
         }
 
@@ -302,9 +306,9 @@ public class DefaultRolloverStrategy imp
 
         String lowFilename = subst.replace(buf);
 
-        if (lowFilename.endsWith(".gz")) {
+        if (lowFilename.endsWith(EXT_GZIP)) {
             suffixLength = 3;
-        } else if (lowFilename.endsWith(".zip")) {
+        } else if (lowFilename.endsWith(EXT_ZIP)) {
             suffixLength = 4;
         }
 
@@ -412,10 +416,10 @@ public class DefaultRolloverStrategy imp
         final String compressedName = renameTo;
         Action compressAction = null;
 
-        if (renameTo.endsWith(".gz")) {
+        if (renameTo.endsWith(EXT_GZIP)) {
             renameTo = renameTo.substring(0, renameTo.length() - 3);
             compressAction = new GZCompressAction(new File(renameTo), new File(compressedName),
true);
-        } else if (renameTo.endsWith(".zip")) {
+        } else if (renameTo.endsWith(EXT_ZIP)) {
             renameTo = renameTo.substring(0, renameTo.length() - 4);
             compressAction = new ZipCompressAction(new File(renameTo), new File(compressedName),
true, 
                     compressionLevel);



Mime
View raw message