rpysz opened a new issue, #2073:
URL: https://github.com/apache/logging-log4j2/issues/2073
## Description
For testing purposes, we create a RollingFileAppender with a cron schedule
that executes every second (0/1 0/1 * 1/1 * ? *). We noticed that we get the
following NullPointerException in random calls.
The cause is most likely the implementation of the method:
org.apache.logging.log4j.core.config.ConfigurationScheduler#scheduleWithCron(org.apache.logging.log4j.core.util.CronExpression,
java.util.Date, java.lang.Runnable)
In the case of a frequently executing schedule, there is sometimes a
situation where CronRunnable starts executing before the
runnable.setScheduledFuture(cronScheduledFuture) method is called, causing an
NPE.
The solution to the problem would be to pass cronScheduledFuture even before
the first launch of CronRunnable or to introduce an initial delay mechanism.
## Configuration
**Version:** 2.17.2
**Operating system:** Ubuntu 22.04.3
**JDK:** Temurin jdk-11.0.21+9
## Logs
```
[2023-12-06T19:28:05.855Z] java.lang.NullPointerException: null
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.config.ConfigurationScheduler$CronRunnable.toString(ConfigurationScheduler.java:256)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.855Z] at java.lang.String.valueOf(String.java:2951)
~[?:?]
[2023-12-06T19:28:05.855Z] at
java.lang.StringBuilder.append(StringBuilder.java:172) ~[?:?]
[2023-12-06T19:28:05.855Z] at
java.util.concurrent.Executors$RunnableAdapter.toString(Executors.java:519)
~[?:?]
[2023-12-06T19:28:05.855Z] at java.lang.String.valueOf(String.java:2951)
~[?:?]
[2023-12-06T19:28:05.855Z] at
java.lang.StringBuilder.append(StringBuilder.java:172) ~[?:?]
[2023-12-06T19:28:05.855Z] at
java.util.concurrent.FutureTask.toString(FutureTask.java:513) ~[?:?]
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.config.ConfigurationScheduler.toString(ConfigurationScheduler.java:272)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.initialize(CronTriggeringPolicy.java:90)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy.initialize(CompositeTriggeringPolicy.java:54)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.appender.rolling.RollingFileManager.setTriggeringPolicy(RollingFileManager.java:431)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.appender.rolling.RollingFileManager.updateData(RollingFileManager.java:710)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.855Z] at
org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:151)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.856Z] at
org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:100)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.856Z] at
org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:217)
~[log4j-core-2.17.2.jar:2.17.2]
[2023-12-06T19:28:05.856Z] at
org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:146)
~[log4j-core-2.17.2.jar:2.17.2]
```
## Reproduction
Endless loop creating RollingFileAppender with cron schedule 0/1 0/1 * 1/1 *
? *
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]