fixed potential NullPointerException if AMQP.Properties::getHeaders returns null (#3588)
This commit is contained in:
parent
9a3734f8ed
commit
016a963640
|
@ -6,6 +6,7 @@
|
|||
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) {
|
||||
Object obj = carrier.get(key);
|
||||
return obj == null ? null : obj.toString();
|
||||
if (carrier != null) {
|
||||
Object obj = carrier.get(key);
|
||||
return obj == null ? null : obj.toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue