diff --git a/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala b/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala index b2c3a7454..ee8da0bd9 100644 --- a/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala +++ b/instrumentation/kamon-pekko/src/main/scala/kamon/instrumentation/pekko/instrumentations/DispatcherInstrumentation.scala @@ -167,9 +167,10 @@ object ThreadPoolConfigCopyAdvice { @Advice.OnMethodExit @static def exit(@Advice.This original: Any, @Advice.Return copy: Any): Unit = { - copy.asInstanceOf[HasDispatcherPrerequisites].setDispatcherPrerequisites( - original.asInstanceOf[HasDispatcherPrerequisites].dispatcherPrerequisites - ) + val prereqs = original.asInstanceOf[HasDispatcherPrerequisites].dispatcherPrerequisites + if (prereqs != null) { + copy.asInstanceOf[HasDispatcherPrerequisites].setDispatcherPrerequisites(prereqs) + } copy.asInstanceOf[HasDispatcherName].setDispatcherName(original.asInstanceOf[HasDispatcherName].dispatcherName) } }