Java APM Agent: ERROR co.elastic.apm.agent.bci.IndyBootstrap - Advice threw an exception, this should never happen! java.lang.NullPointerException

Kibana version: 8.7.0

Elasticsearch version: 8.7.0

APM Server version: 8.7.0

APM Agent language and version: java/1.45.0

Fresh install or upgraded from other version? Fresh install

Is there anything special in your setup? Nothing specific

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

Hello,

We stumbled on an issue when tried to use the Annotation API and the annotation inheritance feature.

We have an interface with method A() and multiple classes implementing that method, so I added the @CaptureSpan annotation on the interface method and also added the needed configurations to the elasticapm.properties file:

enable_public_api_annotation_inheritance=true

application_packages=..

What I understand from the documentation is that the span should be created automatically for each class that implements the interface but instead, we're hitting the following error for each inherited subclass method execution:

ERROR co.elastic.apm.agent.bci.IndyBootstrap - Advice threw an exception, this should never happen!

java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "spanName" is null

at co.elastic.apm.agent.pluginapi.CaptureSpanInstrumentation$AdviceClass.onMethodEnter(CaptureSpanInstrumentation.java:106)

The same goes for the case when we have a hierarchy on multiple levels:

On the first level, we have an abstract class A, on the second level we have a class B that extends A, and on the last level we have multiple classes that extend B. The problem appears when we have a method in some of the classes that are at the lowest level, which method overrides a method of the class A (the highest level), but the same method is not present in the direct parent class, i.e. class B. We’ve added an @CaptureSpan annotation to the method in class A and what we expect is that the span should be inherited from all subclasses, no matter how deep in the hierarchy they are. But instead, when the method which is in the classes at the lowest level gets executed, we receive the exception above.
Do you know what might be causing this error or is this the expected behavior?

Provide logs and/or server output (if relevant):

ERROR co.elastic.apm.agent.bci.IndyBootstrap - Advice threw an exception, this should never happen!

java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because "spanName" is null

at co.elastic.apm.agent.pluginapi.CaptureSpanInstrumentation$AdviceClass.onMethodEnter(CaptureSpanInstrumentation.java:106)

Thanks for reporting this, after looking at the code it indeed looks like our annotation scanning algorithm is flawed here. I've created an issue you can follow.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.