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

com.undefinedlabs.scope.rules.propagation.carriers.URLConnectionInjectAdapter Maven / Gradle / Ivy

Go to download

Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly identify, troubleshoot and fix failed builds. This artifact contains the classes to instrument the Java NET package.

There is a newer version: 0.15.1-beta.2
Show newest version
package com.undefinedlabs.scope.rules.propagation.carriers;

import io.opentracing.propagation.TextMap;
import com.undefinedlabs.scope.deps.org.apache.commons.lang3.StringUtils;

import java.net.URLConnection;
import java.util.Iterator;
import java.util.Map;

public class URLConnectionInjectAdapter implements TextMap {

    private final URLConnection urlConnection;

    public URLConnectionInjectAdapter(final URLConnection urlConnection) {
        this.urlConnection = urlConnection;
    }

    @Override
    public Iterator> iterator() {
        throw new UnsupportedOperationException("Should be used only with tracer#inject()");
    }

    @Override
    public void put(String key, String value) {
        if (StringUtils.isNotEmpty(value)) {
            this.urlConnection.setRequestProperty(key, value);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy