All Downloads are FREE. Search and download functionalities are using the official Maven repository.

feign.opentracing.HttpHeadersInjectAdapter Maven / Gradle / Ivy

There is a newer version: 0.4.1
Show newest version
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()");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy