Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22B771037D for ; Sun, 9 Feb 2014 19:50:46 +0000 (UTC) Received: (qmail 53567 invoked by uid 500); 9 Feb 2014 19:50:45 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 53539 invoked by uid 500); 9 Feb 2014 19:50:45 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 53530 invoked by uid 99); 9 Feb 2014 19:50:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Feb 2014 19:50:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Feb 2014 19:50:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E4CE72388868; Sun, 9 Feb 2014 19:50:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@logging.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140209195023.E4CE72388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);