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

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


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 2451c3e  Trim MaxBackupIndex if last char is blank. (#755)
2451c3e is described below

commit 2451c3eca3a7f79d2053f01ea3286a00a9ffa40a
Author: Marcus Hoja <[email protected]>
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 9b80bcb..43a789f 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
@@ -134,7 +134,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);

Reply via email to