Check if span name is null before use
MODIFY
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/build.gradle.kts
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/build.gradle.kts
@@ -5,4 +5,6 @@ plugins {
dependencies {
compileOnly("javax.servlet:javax.servlet-api:3.0.1")
compileOnly("org.apache.cxf:cxf-rt-frontend-jaxws:3.0.0")
+
+ testImplementation("org.apache.cxf:cxf-rt-frontend-jaxws:3.0.0")
}

MODIFY
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/CxfHelper.java
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/main/java/io/opentelemetry/javaagent/instrumentation/cxf/CxfHelper.java
@@ -26,10 +26,15 @@ public final class CxfHelper {
Context parentContext = Context.current();
CxfRequest request = new CxfRequest(message);
+
+ if (!request.shouldCreateSpan()) {
+ return;
+ }
+
ServerSpanNaming.updateServerSpanName(
parentContext, CONTROLLER, CxfServerSpanNaming.SERVER_SPAN_NAME, request);
- if (!request.shouldCreateSpan() || !instrumenter().shouldStart(parentContext, request)) {
+ if (!instrumenter().shouldStart(parentContext, request)) {
return;
}

ADD
instrumentation/jaxws/jaxws-2.0-cxf-3.0/library/src/test/java/io/opentelemetry/javaagent/instrumentation/cxf/TracingStartInInterceptorTest.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.cxf;
+
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.junit.jupiter.api.Test;
+
+class TracingStartInInterceptorTest {
+
+ @Test
+ void shouldNotThrowExceptionIfSpanNameIsNull() {
+ // given Exchange without BindingOperationInfo.class -> spanName eq null
+ Message message = new MessageImpl();
+ message.setExchange(new ExchangeImpl());
+
+ // when interceptor handling message
+ TracingStartInInterceptor tracingStartInInterceptor = new TracingStartInInterceptor();
+ tracingStartInInterceptor.handleMessage(message);
+
+ // then no NPE
+ }
+}

Check if span name is null before use (#4277)