Skip to content

Commit 47a760b

Browse files
amarzialidevflow.devflow-routing-intake
andauthored
Do not use null parent context on tomcat advice (#11968)
Do not use null parent context on tomcat advice enforce nonnull checks Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 92779f6 commit 47a760b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public Context extract(REQUEST_CARRIER carrier) {
166166
* @param parentContext The parent context of the span to create.
167167
* @return A new context bundling the span, child of the given parent context.
168168
*/
169-
public Context startSpan(REQUEST_CARRIER carrier, Context parentContext) {
169+
public Context startSpan(REQUEST_CARRIER carrier, @Nonnull Context parentContext) {
170170
String instrumentationName = component().toString();
171171
AgentSpanContext extracted = getExtractedSpanContext(parentContext);
172172
// Call IG callbacks

dd-java-agent/instrumentation/tomcat/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/TomcatServerInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static void onService(
151151
}
152152
final Object parentContextObj = req.getAttribute(DD_PARENT_CONTEXT_ATTRIBUTE);
153153
final Context parentContext =
154-
(parentContextObj instanceof Context) ? (Context) parentContextObj : null;
154+
(parentContextObj instanceof Context) ? (Context) parentContextObj : rootContext();
155155

156156
final Context context = DECORATE.startSpan(req, parentContext);
157157
serverScope = context.attach();

0 commit comments

Comments
 (0)