Skip to content

Commit 9d65e9b

Browse files
authored
Avoid relocating com.kenai.jffi in dd-trace-ot (DataDog#4779)
because it contains native methods that have to match to the embedded native libraries
1 parent f5f8b06 commit 9d65e9b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Diff for: dd-trace-ot/build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ shadowJar {
9090
exclude(dependency('org.slf4j:'))
9191
}
9292

93-
relocate('com.', 'ddtrot.com.')
93+
relocate('com.', 'ddtrot.com.') {
94+
// don't relocate native methods
95+
exclude('com.kenai.jffi.*')
96+
exclude('com.kenai.jffi.internal.*')
97+
}
9498
relocate('dogstatsd/', 'ddtrot/dogstatsd/')
9599
relocate('jni/', 'ddtrot/jni/')
96100
relocate('jnr/', 'ddtrot/jnr/')

Diff for: test-published-dependencies/ot-is-shaded/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ tasks.register('checkJarContents', CheckJarContentsTask) {
9191
'^[^/]*\\.version$',
9292
'^DDSketch.proto$',
9393
'^META-INF/.*$',
94+
'^com/$',
95+
'^com/kenai/$',
96+
'^com/kenai/jffi/.*$',
9497
'^datadog/.*$',
9598
'^ddtrot/.*$'
9699
]

Diff for: test-published-dependencies/ot-pulls-in-api/src/test/java/CreateTracerTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import datadog.opentracing.DDTracer;
22
import io.opentracing.util.GlobalTracer;
33
import org.junit.jupiter.api.Test;
4+
import java.nio.file.Files;
5+
import java.nio.file.Path;
46

57
public class CreateTracerTest {
68

@@ -13,4 +15,18 @@ void createTracer() throws InterruptedException {
1315
// Sleep a bit so the trace sending machinery has a chance to start
1416
Thread.sleep(1000);
1517
}
18+
19+
@Test
20+
void buildTracerWithUDS() throws Exception {
21+
// trigger use of JNR and JFFI to validate native method linking
22+
Path fakeSocketPath = Files.createTempFile("dd-java", "test-uds");
23+
System.setProperty("dd.trace.agent.url", "unix://" + fakeSocketPath.toUri().getPath());
24+
try {
25+
// we don't need to actually use the tracer, just build it
26+
DDTracer.builder().serviceName("TestServiceWithUDS").build();
27+
} finally {
28+
System.clearProperty("dd.trace.agent.url");
29+
Files.delete(fakeSocketPath);
30+
}
31+
}
1632
}

0 commit comments

Comments
 (0)