Prevent case where call depth might never be reset
MODIFY
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/PreparedStatementInstrumentation.java
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/PreparedStatementInstrumentation.java
@@ -18,6 +18,7 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import datadog.trace.bootstrap.JDBCMaps;
import io.opentracing.Scope;
import io.opentracing.Span;
+import io.opentracing.noop.NoopScopeManager.NoopScope;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.sql.Connection;
@@ -61,7 +62,7 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Configu
connection = statement.getConnection();
} catch (final Throwable e) {
// Had some problem getting the connection.
- return null;
+ return NoopScope.INSTANCE;
}
JDBCMaps.DBInfo dbInfo = JDBCMaps.connectionInfo.get(connection);

MODIFY
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
@@ -18,6 +18,7 @@ import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import datadog.trace.bootstrap.JDBCMaps;
import io.opentracing.Scope;
import io.opentracing.Span;
+import io.opentracing.noop.NoopScopeManager.NoopScope;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import java.sql.Connection;
@@ -60,7 +61,7 @@ public final class StatementInstrumentation extends Instrumenter.Configurable {
connection = statement.getConnection();
} catch (final Throwable e) {
// Had some problem getting the connection.
- return null;
+ return NoopScope.INSTANCE;
}
JDBCMaps.DBInfo dbInfo = JDBCMaps.connectionInfo.get(connection);

Prevent case where call depth might never be reset