Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-358

slf4j-log4j12 initialization should be thread safe

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.19
    • Component/s: None
    • Labels:
      None

      Description

      MultithreadedInitializationTest in slf4j-log4j12fails (see below) because LogManier initialization occurs called via Log4jLoggerFactory.getLogger. Thus a log4j Logger may be used before it is actually initialized.

      THREAD_COUNT=8
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.033 sec <<< FAILURE! - in org.slf4j.impl.MultithreadedInitializationTest
      multiThreadedInitialization(org.slf4j.impl.MultithreadedInitializationTest)  Time elapsed: 0.027 sec  <<< ERROR!
      java.lang.NullPointerException
      	at org.slf4j.impl.MultithreadedInitializationTest.getRecordedEvents(MultithreadedInitializationTest.java:84)
      	at org.slf4j.impl.MultithreadedInitializationTest.multiThreadedInitialization(MultithreadedInitializationTest.java:76)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      
      Results :
      Tests in error: 
        MultithreadedInitializationTest.multiThreadedInitialization:76->getRecordedEvents:84 NullPointer
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ceki Ceki Gülcü
                Reporter:
                ceki Ceki Gülcü
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: