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;
|
package io.opentelemetry.javaagent.instrumentation.rabbitmq;
|
||||||
|
|
||||||
import io.opentelemetry.context.propagation.TextMapGetter;
|
import io.opentelemetry.context.propagation.TextMapGetter;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TextMapExtractAdapter implements TextMapGetter<Map<String, Object>> {
|
public class TextMapExtractAdapter implements TextMapGetter<Map<String, Object>> {
|
||||||
|
@ -14,12 +15,16 @@ public class TextMapExtractAdapter implements TextMapGetter<Map<String, Object>>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> keys(Map<String, Object> carrier) {
|
public Iterable<String> keys(Map<String, Object> carrier) {
|
||||||
return carrier.keySet();
|
return carrier != null ? carrier.keySet() : Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Map<String, Object> carrier, String key) {
|
public String get(Map<String, Object> carrier, String key) {
|
||||||
Object obj = carrier.get(key);
|
if (carrier != null) {
|
||||||
return obj == null ? null : obj.toString();
|
Object obj = carrier.get(key);
|
||||||
|
return obj == null ? null : obj.toString();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue