You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/11/16 12:30:00 UTC

[jira] [Commented] (LOG4J2-2510) RollingRandomAccessFileManager throws NPE in closeOutputStream on shutdown

    [ https://issues.apache.org/jira/browse/LOG4J2-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689357#comment-16689357 ] 

ASF GitHub Bot commented on LOG4J2-2510:
----------------------------------------

GitHub user Blindfold opened a pull request:

    https://github.com/apache/logging-log4j2/pull/240

    Fix LOG4J2-2510 NullPointerException during shutdown

    This should fix LOG4J2-2510
    
    NullPointerEception gets thrown while executing shutdown hook in configuration with RollingRandomAccessFile appender and DirectWriteRolloverStrategy strategy. It happens when no messages logged during the session and thus no log file created.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Blindfold/logging-log4j2 master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/logging-log4j2/pull/240.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #240
    
----
commit c6ee15c269c986a8c5b66bb9ba87850e4efd3de1
Author: Blindfold <tm...@...>
Date:   2018-11-16T12:00:44Z

    Fix LOG4J2-2510 NullPointerException during shutdown

----


> RollingRandomAccessFileManager throws NPE in closeOutputStream on shutdown
> --------------------------------------------------------------------------
>
>                 Key: LOG4J2-2510
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2510
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.11.1
>         Environment: Example config:
> status = TRACE
> dest = err
> name = testconfig
> appender.message.type = RollingRandomAccessFile
> appender.message.name = Message
> appender.message.append = true
> appender.message.immediateFlush = true
> appender.message.filePattern = ${sys:user.home}/log/%d\{MMddyyHH}00.Message.log
> appender.message.layout.type = PatternLayout
> appender.message.layout.pattern = %d\{yyyy.MM.dd HH:mm:ss.sss} %p [%t] %m%ex%n%n
> appender.message.policy.type = CronTriggeringPolicy
> appender.message.policy.schedule = 0 0 * * * ?
> appender.message.policy.evaluateOnStartup = true
> appender.message.filter.threshold.type = ThresholdFilter
> appender.message.filter.threshold.level = WARNING
> appender.message.strategy.type = DirectWriteRolloverStrategy
> appender.message.strategy.maxFiles = 999999
> rootLogger.level = ALL
> rootLogger.includeLocation = false
> rootLogger.appenderRef.message.ref = Message
>  
>            Reporter: Denis Kozlov
>            Priority: Minor
>
> In configuration where RollingRandomAccessFile appender is used together with DirectWriteRolloverStrategy strategy and no messages got logged in a session I'm getting NullPointerException when closing the application.
> Exception call stack is:
> 2018-11-16 13:53:01,221 pool-1-thread-1 ERROR Caught exception executing shutdown hook null java.lang.NullPointerException
>  at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.closeOutputStream(RollingRandomAccessFileManager.java:168)
>  at org.apache.logging.log4j.core.appender.OutputStreamManager.releaseSub(OutputStreamManager.java:136)
>  at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.releaseSub(RollingFileManager.java:266)
>  at org.apache.logging.log4j.core.appender.AbstractManager.stop(AbstractManager.java:86)
>  at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.stop(AbstractOutputStreamAppender.java:142)
>  at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.stop(RollingRandomAccessFileAppender.java:223)
>  at org.apache.logging.log4j.core.config.AbstractConfiguration.stop(AbstractConfiguration.java:360)
>  at org.apache.logging.log4j.core.LoggerContext.stop(LoggerContext.java:353)
>  at org.apache.logging.log4j.core.LoggerContext$1.run(LoggerContext.java:281)
>  at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry$RegisteredCancellable.run(DefaultShutdownCallbackRegistry.java:109)
>  at org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry.run(DefaultShutdownCallbackRegistry.java:74)
>  at java.lang.Thread.run(Thread.java:745)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)