[slf4j-dev] [Bug 78] New: NullpointerException

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Tue Apr 1 10:48:06 CEST 2008


http://bugzilla.slf4j.org/show_bug.cgi?id=78

           Summary: NullpointerException
           Product: SLF4J
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Core API
        AssignedTo: dev at slf4j.org
        ReportedBy: venugopalt at ibsplc.com


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?


-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the slf4j-dev mailing list