Skip to content

Commit d368c77

Browse files
fix: Prevent NPE setting null span baggage (#7848)
The baggage collection don’t handle null. Prevent throwing exception due to bad API call.
1 parent 3ce02c9 commit d368c77

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@ public long getEndToEndStartTime() {
642642
}
643643

644644
public void setBaggageItem(final String key, final String value) {
645+
if (key == null || value == null) {
646+
log.debug("Try to set invalid baggage: key = {}, value = {}", key, value);
647+
return;
648+
}
645649
if (baggageItems == EMPTY_BAGGAGE) {
646650
synchronized (this) {
647651
if (baggageItems == EMPTY_BAGGAGE) {

0 commit comments

Comments
 (0)