Check if span name is null before use (#4277)
This commit is contained in:
parent
300e7dab7e
commit
90c0df9328
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue