Handle null header values (DataDog/dd-trace-java#1650)
MODIFY
instrumentation/kafka-clients-0.11/src/main/java/io/opentelemetry/auto/instrumentation/kafkaclients/TextMapExtractAdapter.java
instrumentation/kafka-clients-0.11/src/main/java/io/opentelemetry/auto/instrumentation/kafkaclients/TextMapExtractAdapter.java
@@ -31,6 +31,10 @@ public class TextMapExtractAdapter implements HttpTextFormat.Getter<Headers> {
if (header == null) {
return null;
}
- return new String(header.value(), StandardCharsets.UTF_8);
+ byte[] value = header.value();
+ if (value == null) {
+ return null;
+ }
+ return new String(value, StandardCharsets.UTF_8);
}
}

MODIFY
instrumentation/kafka-streams-0.11/src/main/java/io/opentelemetry/auto/instrumentation/kafkastreams/TextMapExtractAdapter.java
instrumentation/kafka-streams-0.11/src/main/java/io/opentelemetry/auto/instrumentation/kafkastreams/TextMapExtractAdapter.java
@@ -31,6 +31,10 @@ public class TextMapExtractAdapter implements HttpTextFormat.Getter<Headers> {
if (header == null) {
return null;
}
- return new String(header.value(), StandardCharsets.UTF_8);
+ byte[] value = header.value();
+ if (value == null) {
+ return null;
+ }
+ return new String(value, StandardCharsets.UTF_8);
}
}

Handle null header values (DataDog/dd-trace-java#1650)