Remove nested if.
MODIFY
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/JaxRsAnnotationsInstrumentation.java
dd-java-agent/instrumentation/jax-rs-annotations-2/src/main/java/datadog/trace/instrumentation/jaxrs2/JaxRsAnnotationsInstrumentation.java
@@ -140,11 +140,11 @@ public final class JaxRsAnnotationsInstrumentation extends Instrumenter.Default
return;
}
- if (asyncResponse == null || !asyncResponse.isSuspended()) {
if (asyncResponse != null && !asyncResponse.isSuspended()) {
- // Clear span from the asyncResponse
+ // Clear span from the asyncResponse. Logically this should never happen. Added to be safe.
InstrumentationContext.get(AsyncResponse.class, AgentSpan.class).put(asyncResponse, null);
}
+ if (asyncResponse == null || !asyncResponse.isSuspended()) {
DECORATE.beforeFinish(span);
span.finish();
}

Remove nested if.