Skip to content

Commit

Permalink
Resteasy: compile instrumentation against earliest supported version (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Aug 7, 2021
1 parent 96b9e22 commit f80d0ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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> {
Expand All @@ -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);
}
}

0 comments on commit f80d0ae

Please sign in to comment.