fixed potential NullPointerException if AMQP.Properties::getHeaders returns null
MODIFY
instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/TextMapExtractAdapter.java
instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/TextMapExtractAdapter.java
package io.opentelemetry.javaagent.instrumentation.rabbitmq;
import io.opentelemetry.context.propagation.TextMapGetter;
+import java.util.Collections;
import java.util.Map;
public class TextMapExtractAdapter implements TextMapGetter<Map<String, Object>> {
@@ -14,12 +15,16 @@ public class TextMapExtractAdapter implements TextMapGetter<Map<String, Object>>
@Override
public Iterable<String> keys(Map<String, Object> carrier) {
- return carrier.keySet();
+ return carrier != null ? carrier.keySet() : Collections.emptyList();
}
@Override
public String get(Map<String, Object> carrier, String key) {
+ if (carrier != null) {
Object obj = carrier.get(key);
return obj == null ? null : obj.toString();
+ } else {
+ return null;
+ }
}
}

fixed potential NullPointerException if AMQP.Properties::getHeaders returns null (#3588)