Resteasy: compile instrumentation against earliest supported version
MODIFY
instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/build.gradle.kts
instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/build.gradle.kts
@@ -11,23 +11,7 @@ muzzle {
}
dependencies {
- // compiling against a version prior to 3.0.10.Final will bind the call in ResteasyInjectAdapter:
- // carrier.getHeaders().getHeaders().putSingle(key, value)
- // to:
- // org.jboss.resteasy.util.CaseInsensitiveMap#putSingle(Ljava/lang/String;Ljava/lang/Object;)V
- // which will be incompatible with 3.0.10.Final and later, where that API was changed to:
- // org.jboss.resteasy.util.CaseInsensitiveMap#putSingle(Ljava/lang/Object;Ljava/lang/Object;)V
- //
- // conversely, however:
- // compiling against 3.0.10.Final will bind the call in ResteasyInjectAdapter:
- // carrier.getHeaders().getHeaders().putSingle(key, value)
- // to:
- // org.jboss.resteasy.util.CaseInsensitiveMap#putSingle(Ljava/lang/Object;Ljava/lang/Object;)V
- // which WILL be compatible with versions prior to 3.0.10.Final, because in those versions
- // putSingle(String, Object) is a generic implementation(for)
- // javax.ws.rs.core.MultivaluedMap.putSingle(K, V), and so there's also a synthetic bridge method
- // putSingle(Object, Object) in those versions
- library("org.jboss.resteasy:resteasy-client:3.0.10.Final")
+ library("org.jboss.resteasy:resteasy-client:3.0.0.Final")
implementation(project(":instrumentation:jaxrs-client:jaxrs-client-2.0:jaxrs-client-2.0-common:javaagent"))
}

MODIFY
instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyInjectAdapter.java
instrumentation/jaxrs-client/jaxrs-client-2.0/jaxrs-client-2.0-resteasy-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v2_0/ResteasyInjectAdapter.java
package io.opentelemetry.javaagent.instrumentation.jaxrsclient.v2_0;
import io.opentelemetry.context.propagation.TextMapSetter;
+import javax.ws.rs.core.MultivaluedMap;
import org.jboss.resteasy.client.jaxrs.internal.ClientInvocation;
public final class ResteasyInjectAdapter implements TextMapSetter<ClientInvocation> {
@@ -15,6 +16,11 @@ public final class ResteasyInjectAdapter implements TextMapSetter<ClientInvocati
@Override
public void set(ClientInvocation carrier, String key, String value) {
// Don't allow duplicates.
- carrier.getHeaders().getHeaders().putSingle(key, value);
+ // Using MultivaluedMap instead of CaseInsensitiveMap returned by getHeaders because in versions
+ // prior to 3.0.10.Final CaseInsensitiveMap has putSingle(String, Object) which is not present
+ // in later versions. Going through MultivaluedMap ensures that we'll be calling
+ // putSingle(Object, Object) that is present in all versions.
+ MultivaluedMap<String, Object> map = carrier.getHeaders().getHeaders();
+ map.putSingle(key, value);
}
}

Resteasy: compile instrumentation against earliest supported version (#3777)