Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-6088

NPE in LoggerImpl when formatted logger called with null or empty arguments

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: log-1.2.0
    • Fix Version/s: None
    • Component/s: Log Service
    • Labels:

      Description

      When calling the "formatter" logger with null or empty arguments like the following sample code (using bnd launchpad):

      import org.junit.Test;
      import org.osgi.service.log.Logger;
      import org.osgi.service.log.LoggerFactory;
      
      import aQute.launchpad.Launchpad;
      import aQute.launchpad.LaunchpadBuilder;
      
      public class FelixLoggerTest {
      
          @Test
          public void letApacheFelixLogThrowNPE() throws Exception {
              try (final Launchpad launchpad = new LaunchpadBuilder().runfw("org.apache.felix.framework").bundles("org.apache.felix.log;version='[1.2.0,1.2.1)'").create()) {
                  LoggerFactory osgiLoggerFactory = launchpad.getService(LoggerFactory.class).get();
                  Logger osgiLogger = osgiLoggerFactory.getLogger(getClass().getName());
      
                  osgiLogger.info("Test formatted logging...", new Object[0]); // throws NPE
                  osgiLogger.debug("Test formatted logging...", null); // throws NPE
              }
          }
      }
      
      

      following NPE is thrown:

      java.lang.NullPointerException
      at org.apache.felix.log.LoggerImpl.format(LoggerImpl.java:335)
      at org.apache.felix.log.LoggerImpl.info(LoggerImpl.java:164)
      at com.[REDACTED].run.FelixLoggerTest.letApacheFelixLogThrowNPE(FelixLoggerTest.java:21)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rotty3000 Raymond Augé
                Reporter:
                dahoc Jan Hendriks
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: