feign.opentracing.HttpHeadersInjectAdapter Maven / Gradle / Ivy
package feign.opentracing;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import io.opentracing.propagation.TextMap;
/**
* Inject adapter for HTTP headers see {@link io.opentracing.Tracer#inject}.
*
* @author Pavol Loffay
*/
class HttpHeadersInjectAdapter implements TextMap {
private Map> headers;
public HttpHeadersInjectAdapter(Map> headers) {
if (headers == null) {
throw new NullPointerException("Headers should not be null!");
}
this.headers = headers;
}
@Override
public void put(String key, String value) {
Collection values = headers.get(key);
if (values == null) {
values = new ArrayList<>(1);
headers.put(key, values);
}
values.add(value);
}
@Override
public Iterator> iterator() {
throw new UnsupportedOperationException("This class should be used only with tracer#inject()");
}
}