Skip to content

Commit 71bbdc6

Browse files
authored
Review fixes for jdbc:javaagent (#18061)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 95d199d commit 71bbdc6

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/DriverInstrumentation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
2020
import java.sql.Connection;
2121
import java.util.Properties;
22+
import javax.annotation.Nullable;
2223
import net.bytebuddy.asm.Advice;
2324
import net.bytebuddy.description.type.TypeDescription;
2425
import net.bytebuddy.matcher.ElementMatcher;
@@ -52,7 +53,7 @@ public static class DriverAdvice {
5253
public static void addDbInfo(
5354
@Advice.Argument(0) String url,
5455
@Advice.Argument(1) Properties props,
55-
@Advice.Return Connection connection) {
56+
@Advice.Return @Nullable Connection connection) {
5657
if (connection == null) {
5758
// Exception was probably thrown.
5859
return;

instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/datasource/DataSourceInstrumentation.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public static class GetConnectionAdvice {
4444

4545
public static class AdviceScope {
4646
private final CallDepth callDepth;
47-
private final Context context;
48-
private final Scope scope;
47+
@Nullable private final Context context;
48+
@Nullable private final Scope scope;
4949

50-
private AdviceScope(CallDepth callDepth, Context context, Scope scope) {
50+
private AdviceScope(CallDepth callDepth, @Nullable Context context, @Nullable Scope scope) {
5151
this.callDepth = callDepth;
5252
this.context = context;
5353
this.scope = scope;
@@ -75,7 +75,8 @@ public static AdviceScope start(DataSource ds) {
7575
return new AdviceScope(callDepth, context, context.makeCurrent());
7676
}
7777

78-
public void end(@Nullable Throwable throwable, DataSource ds, Connection connection) {
78+
public void end(
79+
@Nullable Throwable throwable, DataSource ds, @Nullable Connection connection) {
7980
if (callDepth.decrementAndGet() > 0) {
8081
return;
8182
}

0 commit comments

Comments
 (0)