Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1420

2.6.1 - NPE due to OnStartupTriggeringPolicy changes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.1
    • Fix Version/s: 2.6.2
    • Component/s: None
    • Labels:
      None

      Description

      Hi,

      Noticed an NPE with one of our configurations with 2.6.1 (doesn't happen on previous versions). Looks like it's due to changes for LOG4J2-1405. Looks like the file size in RollingFileManager constructor is set before the randomAccessFile in RollingRandomAccessFileManager ctor. And the actual policy triggering happens in RollingFileManager before the randomAccessFile is assigned:triggeringPolicy.initialize(this); I guess that's why there was somewhat an elaborate logic in previous version of OnStartupTriggeringPolicy and the actual rollover was decided in isTriggeringEvent.

      The NPE always happens with OnStartupTriggeringPolicy and if previous file is not empty.

      2016-06-09 13:38:57,060 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile. java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)
      	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
      	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
      	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
      	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
      	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
      	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
      	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:491)
      	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:561)
      	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
      	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
      	at org.apache.logging.log4j.core.async.AsyncLoggerContext.start(AsyncLoggerContext.java:75)
      	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
      	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
      	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
      	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
      	at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
      	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
      	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
      	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
      	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
      	at com.tradingscreen.gemfire.server.CacheServer.<clinit>(CacheServer.java:46)
      Caused by: java.lang.NullPointerException
      	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.close(RollingRandomAccessFileManager.java:128)
      	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:211)
      	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:142)
      	at org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy.initialize(OnStartupTriggeringPolicy.java:43)
      	at org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy.initialize(CompositeTriggeringPolicy.java:49)
      	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.<init>(RollingFileManager.java:77)
      	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.<init>(RollingRandomAccessFileManager.java:50)
      	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:183)
      	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:147)
      	at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:73)
      	at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:81)
      	at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.getRollingRandomAccessFileManager(RollingRandomAccessFileManager.java:80)
      	at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.createAppender(RollingRandomAccessFileAppender.java:207)
      	... 26 more
      
      2016-06-09 13:38:57,064 main ERROR Null object returned for RollingRandomAccessFile in Appenders.
      

        Attachments

          Activity

            People

            • Assignee:
              ralph.goers@dslextreme.com Ralph Goers
              Reporter:
              leonfin Leon Finker
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: