Skip to content

Commit

Permalink
Merge pull request #6018 from luneo7/okhttp-relocate
Browse files Browse the repository at this point in the history
Relocate OkHttp to avoid conflicts
  • Loading branch information
mcculls authored Oct 19, 2023
2 parents 71f86a5 + 91c127b commit 0fecc32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions dd-java-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ ext.generalShadowJarConfig = {
// rewrite dependencies calling Logger.getLogger
relocate 'java.util.logging.Logger', 'datadog.trace.bootstrap.PatchLogger'

final String projectName = "${project.name}"

// Prevents conflict with other OkHttp instances, but don't relocate instrumentation
if (!projectName.equals('instrumentation')) {
relocate 'okhttp3', 'datadog.okhttp3'
relocate 'okio', 'datadog.okio'
}

if (!project.hasProperty("disableShadowRelocate") || !disableShadowRelocate) {
// shadow OT impl to prevent casts to implementation
relocate 'datadog.trace.common', 'datadog.trace.agent.common'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void onExit(
@Advice.Argument(0) Class<?> declaringClass,
@Advice.Return(readOnly = false) boolean linkAtBuildTime) {
// skip AndroidPlatform from build-time linking because we're not building on Android
if ("okhttp3.internal.platform.AndroidPlatform".equals(declaringClass.getName())) {
if ("datadog.okhttp3.internal.platform.AndroidPlatform".equals(declaringClass.getName())) {
linkAtBuildTime = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void onExit() {
"dd-trace-api.version",
"trace/dd-trace-core.version",
"shared/dogstatsd/version.properties",
"shared/okhttp3/internal/publicsuffix/publicsuffixes.gz"
"shared/datadog/okhttp3/internal/publicsuffix/publicsuffixes.gz"
};

for (String original : tracerResources) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ShadowPackageRenamingTest extends Specification {
final URL agentOkioDep =
ddClass
.getClassLoader()
.loadClass("okio.BufferedSink")
.loadClass("datadog.okio.BufferedSink")
.getProtectionDomain()
.getCodeSource()
.getLocation()
Expand Down

0 comments on commit 0fecc32

Please sign in to comment.