Skip to content

Commit a2256f0

Browse files
committed
Avoid NPE on baseDecorator
1 parent fef9d16 commit a2256f0

File tree

1 file changed

+7
-3
lines changed
  • dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator

1 file changed

+7
-3
lines changed

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/BaseDecorator.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public Context beforeFinish(final Context context) {
9191
}
9292

9393
public AgentScope onError(final AgentScope scope, final Throwable throwable) {
94-
onError(scope.span(), throwable);
94+
if (scope != null) {
95+
onError(scope.span(), throwable);
96+
}
9597
return scope;
9698
}
9799

@@ -100,7 +102,7 @@ public AgentSpan onError(final AgentSpan span, final Throwable throwable) {
100102
}
101103

102104
public AgentSpan onError(final AgentSpan span, final Throwable throwable, byte errorPriority) {
103-
if (throwable != null) {
105+
if (throwable != null && span != null) {
104106
span.addThrowable(
105107
throwable instanceof ExecutionException ? throwable.getCause() : throwable,
106108
errorPriority);
@@ -109,7 +111,9 @@ public AgentSpan onError(final AgentSpan span, final Throwable throwable, byte e
109111
}
110112

111113
public ContextScope onError(final ContextScope scope, final Throwable throwable) {
112-
onError(AgentSpan.fromContext(scope.context()), throwable);
114+
if (scope != null) {
115+
onError(AgentSpan.fromContext(scope.context()), throwable);
116+
}
113117
return scope;
114118
}
115119

0 commit comments

Comments
 (0)