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

[JDBC] Throw a AppenderLoggingException instead of an NPE in the JDBC database manager

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0, 2.13.2
    • Appenders, JDBC
    • None

    Description

      A configuration error can lead to a mysterious NPE:

      java.lang.NullPointerException
      	at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.setStatementObject(JdbcDatabaseManager.java:753)
      	at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.setFields(JdbcDatabaseManager.java:739)
      	at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.writeInternal(JdbcDatabaseManager.java:804)
      	at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.writeThrough(JdbcDatabaseManager.java:880)
      	at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.write(AbstractDatabaseManager.java:264)
      	at org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender.append(AbstractDatabaseAppender.java:110)
      	at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:156)
      	at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:129)
      	at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:120)
      	at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
      	at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:543)
      	at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:502)
      	at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:485)
      	at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:460)
      	at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:82)
      	at org.apache.logging.log4j.core.Logger.log(Logger.java:161)
      	at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2198)
      	at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2152)
      	at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2135)
      	at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1836)
      	at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:1290)
      

      Throw a AppenderLoggingException instead, like other places in this class.

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: