Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when logging warnings through logback #634

Closed
ivantopo opened this issue Feb 6, 2020 · 2 comments
Closed

NPE when logging warnings through logback #634

ivantopo opened this issue Feb 6, 2020 · 2 comments

Comments

@ivantopo
Copy link
Contributor

ivantopo commented Feb 6, 2020

When Kamon's initialization needs to log a warning and the Logback instrumentation is present a NPE is thrown because the Logback instrumentation is trying to read Kamon's config before it gets fully initialized. Stack trace:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at kamon.instrumentation.logback.GetPropertyMapMethodInterceptor$.aroundGetMDCPropertyMap(LogbackInstrumentation.scala:92)
    at ch.qos.logback.classic.util.LogbackMDCAdapter.getPropertyMap(LogbackMDCAdapter.java)
    at ch.qos.logback.classic.spi.LoggingEvent.getMDCPropertyMap(LoggingEvent.java:306)
    at ch.qos.logback.classic.spi.LoggingEvent.prepareForDeferredProcessing(LoggingEvent.java:209)
    at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:223)
    at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:102)
    at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
    at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
    at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
    at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
    at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
    at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
    at ch.qos.logback.classic.Logger.warn(Logger.java:692)
    at kamon.Configuration.loadInitialConfiguration(Configuration.scala:75)
    at kamon.Configuration.$init$(Configuration.scala:27)
    at kamon.Kamon$.<init>(Kamon.scala:19)
    at kamon.Kamon$.<clinit>(Kamon.scala)
    at io.otrl.fare_finder.infrastructure.MainApp$.run(MainApp.scala:86)
    at cats.effect.IOApp.$anonfun$main$3(IOApp.scala:67)
    at cats.effect.internals.IOAppPlatform$.mainFiber(IOAppPlatform.scala:37)
    at cats.effect.internals.IOAppPlatform$.main(IOAppPlatform.scala:24)
    at cats.effect.IOApp.main(IOApp.scala:67)
    at cats.effect.IOApp.main$(IOApp.scala:66)
    at io.otrl.fare_finder.infrastructure.MainApp$.main(MainApp.scala:74)
    at io.otrl.fare_finder.infrastructure.MainApp.main(MainApp.scala)
Caused by: java.lang.NullPointerException
    at kamon.instrumentation.logback.LogbackInstrumentation$.readSettings(LogbackInstrumentation.scala:65)
    at kamon.instrumentation.logback.LogbackInstrumentation$.<init>(LogbackInstrumentation.scala:50)
    at kamon.instrumentation.logback.LogbackInstrumentation$.<clinit>(LogbackInstrumentation.scala)
    ... 25 more

Reported by @IgorCandido on Gitter

@jatcwang
Copy link
Contributor

I encountered this issue too.

@Reeebuuk
Copy link

Us too

ivantopo added a commit that referenced this issue Aug 28, 2020
…ing-during-initialization

dump any initial configuration errors to STDERR instead of a logger, fixes #634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants