Details
-
Bug
-
Resolution: Fixed
-
None
-
None
-
None
-
Operating System: Windows XP
Platform: PC
-
critical
-
P2
-
78
Description
Logger logger = LoggerFactory.getLogger("com.mycompany");
String[] parameters = null;
logger.debug("Parameters are {}", parameters);
will throw a NullPointer exception as follows :
Exception in thread "main" java.lang.NullPointerException
at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:136)
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:223)
Obviously the compiler binds the debug method to : logger.debug(format, new Object[])
and to get around this we have to force the other method by using a typecast :
String[] parameters = null;
logger.debug("Parameters are {}", (Object)parameters);
Is there some better way around this ambiguity?