File tree Expand file tree Collapse file tree
instrumentation/apache-httpasyncclient-4/src/test/groovy
testing/src/main/groovy/datadog/trace/agent/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import datadog.trace.agent.test.base.HttpClientTest
22import datadog.trace.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator
3- import io.opentracing.util.GlobalTracer
43import org.apache.http.client.methods.HttpGet
54import org.apache.http.impl.nio.client.HttpAsyncClients
65import org.apache.http.message.BasicHeader
@@ -34,10 +33,7 @@ class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest<ApacheHttpAsy
3433 Future future = client. execute(request, null )
3534 future. get()
3635 if (callback != null ) {
37- // Request span is closed asynchronously even in regards to returned future so we have to wait here.
38- if (GlobalTracer . get(). activeSpan() != null ) {
39- blockUntilChildSpansFinished(1 )
40- }
36+ blockUntilChildSpansFinished(1 )
4137 callback()
4238 }
4339 return 200
Original file line number Diff line number Diff line change @@ -200,6 +200,10 @@ public static void assertTraces(
200200
201201 public void blockUntilChildSpansFinished (final int numberOfSpans ) throws InterruptedException {
202202 final DDSpan span = (DDSpan ) io .opentracing .util .GlobalTracer .get ().activeSpan ();
203+ if (span == null ) {
204+ // If there is no active span avoid getting an NPE
205+ return ;
206+ }
203207 final PendingTrace pendingTrace = span .context ().getTrace ();
204208
205209 while (pendingTrace .size () < numberOfSpans ) {
You can’t perform that action at this time.
0 commit comments