Description
A reconfigure breaks DirectWriteRolloverStrategy which leads to the errors similar to that one:
2017-06-30 10:45:56,010 Log4j2-TF-4-Scheduled-3 ERROR Log4j2 ConfigurationScheduler caught error running command java.lang.NullPointerException: activeFileName at java.util.Objects.requireNonNull(Objects.java:228) at org.apache.logging.log4j.core.appender.rolling.RolloverDescriptionImpl.<init>(RolloverDescriptionImpl.java:60) at org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy.rollover(DirectWriteRolloverStrategy.java:220) at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:388) at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:304) at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.rollover(CronTriggeringPolicy.java:153) at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.access$100(CronTriggeringPolicy.java:43) at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy$CronTrigger.run(CronTriggeringPolicy.java:176) at org.apache.logging.log4j.core.config.ConfigurationScheduler$CronRunnable.run(ConfigurationScheduler.java:230) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
Durring the rollover the system is using the field currentFileName, which might be null after an reconfigure:
org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy#rollover
... Action compressAction = null; final String sourceName = currentFileName; String compressedName = sourceName; ...
Instead of that I'd propose to use getCurrentFileName() directly, to access the field. Doing so the field would be initialised again, if necessary.
org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy#rollover
... Action compressAction = null; final String sourceName = getCurrentFileName(manager); String compressedName = sourceName; ...
Attachments
Attachments
Issue Links
- duplicates
-
LOG4J2-1916 Nullpointer with DirectWriteRolloverStrategy
- Closed