You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2022/02/16 10:16:04 UTC

[logging-log4j2] branch master updated (4e4c1b5 -> 485e489)

This is an automated email from the ASF dual-hosted git repository.

vy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 4e4c1b5  Remove more unused code
     new 00f15a0  Trim MaxBackupIndex if last char is blank. (#755)
     new 485e489  Trim input to Integer.parseInt() in DefaultRolloverStrategy. (#755)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../log4j/core/appender/rolling/DefaultRolloverStrategy.java        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

[logging-log4j2] 02/02: Trim input to Integer.parseInt() in DefaultRolloverStrategy. (#755)

Posted by vy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 485e489658fa2725de8e48e055a491270d514ede
Author: Volkan Yazici <vo...@yazi.ci>
AuthorDate: Wed Feb 16 10:59:11 2022 +0100

    Trim input to Integer.parseInt() in DefaultRolloverStrategy. (#755)
---
 .../logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
index d90e6de..d606756 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
@@ -124,7 +124,7 @@ public class DefaultRolloverStrategy extends AbstractRolloverStrategy {
                 useMax = fileIndex == null || fileIndex.equalsIgnoreCase("max");
                 minIndex = MIN_WINDOW_SIZE;
                 if (min != null) {
-                    minIndex = Integer.parseInt(min);
+                    minIndex = Integer.parseInt(min.trim());
                     if (minIndex < 1) {
                         LOGGER.error("Minimum window size too small. Limited to " + MIN_WINDOW_SIZE);
                         minIndex = MIN_WINDOW_SIZE;
@@ -139,7 +139,7 @@ public class DefaultRolloverStrategy extends AbstractRolloverStrategy {
                     }
                 }
             }
-            final int compressionLevel = Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION);
+            final int compressionLevel = Integers.parseInt(compressionLevelStr.trim(), Deflater.DEFAULT_COMPRESSION);
             // The config object can be null when this object is built programmatically.
             final StrSubstitutor nonNullStrSubstitutor = config != null ? config.getStrSubstitutor() : new StrSubstitutor();
             return new DefaultRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, nonNullStrSubstitutor,

[logging-log4j2] 01/02: Trim MaxBackupIndex if last char is blank. (#755)

Posted by vy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 00f15a07ac2808dee36f9dfabf62a5e62ab4eee2
Author: Marcus Hoja <51...@users.noreply.github.com>
AuthorDate: Wed Feb 16 10:55:22 2022 +0100

    Trim MaxBackupIndex if last char is blank. (#755)
    
    `log4j.properties` containing `MaxBackupIndex` with trailing whitespace
    causes `log4j-1.2-bridge` to fail silently due to `NumberFormatException`.
---
 .../logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
index 0facba8..d90e6de 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
@@ -132,7 +132,7 @@ public class DefaultRolloverStrategy extends AbstractRolloverStrategy {
                 }
                 maxIndex = DEFAULT_WINDOW_SIZE;
                 if (max != null) {
-                    maxIndex = Integer.parseInt(max);
+                    maxIndex = Integer.parseInt(max.trim());
                     if (maxIndex < minIndex) {
                         maxIndex = minIndex < DEFAULT_WINDOW_SIZE ? DEFAULT_WINDOW_SIZE : minIndex;
                         LOGGER.error("Maximum window size must be greater than the minimum windows size. Set to " + maxIndex);