Details
Description
when I build the appender with 'JdbcAppender.createAppender' ,
in static class JdbcDatabaseManagerFactory, the method createManager has exception that is not catched. The code as follows:
//代码占位符 StringBuilder sb = (new StringBuilder("insert into ")).append(data.tableName).append(" ("); JdbcDatabaseManager.appendColumnNames("INSERT", data, sb); sb.append(") values ("); int i = 1; ColumnMapping[] arr$ = data.columnMappings; int len$ = arr$.length; int len$; for(len$ = 0; len$ < len$; ++len$) { ColumnMapping mapping = arr$[len$]; String mappingName = mapping.getName(); if (Strings.isNotEmpty(mapping.getLiteralValue())) { JdbcDatabaseManager.logger().trace("Adding INSERT VALUES literal for ColumnMapping[{}]: {}={} ", i, mappingName, mapping.getLiteralValue()); sb.append(mapping.getLiteralValue()); } else if (Strings.isNotEmpty(mapping.getParameter())) { JdbcDatabaseManager.logger().trace("Adding INSERT VALUES parameter for ColumnMapping[{}]: {}={} ", i, mappingName, mapping.getParameter()); sb.append(mapping.getParameter()); } else { JdbcDatabaseManager.logger().trace("Adding INSERT VALUES parameter marker for ColumnMapping[{}]: {}={} ", i, mappingName, '?'); sb.append('?'); } sb.append(','); ++i; }
because I wanto use columnConfig, and the variable 'columnMappings' is null, so there mayby a NullPointerException here.....
the stack as follow
//代码占位符
Caused by: java.lang.NullPointerException
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.appendColumnNames(JdbcDatabaseManager.java:342) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.access$100(JdbcDatabaseManager.java:62) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager$JdbcDatabaseManagerFactory.createManager(JdbcDatabaseManager.java:113) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager$JdbcDatabaseManagerFactory.createManager(JdbcDatabaseManager.java:104) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.getManager(AbstractDatabaseManager.java:87) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager.getManager(JdbcDatabaseManager.java:446) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender$Builder.build(JdbcAppender.java:95) ~[log4j-core-2.11.2.jar:2.11.2]
at org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender.createAppender(JdbcAppender.java:202) ~[log4j-core-2.11.2.jar:2.11.2]