Skip to content

Commit 637e27e

Browse files
author
Andrew Kent
committed
Explicitly inject on httpclientbuilder's classloader
1 parent e7869cd commit 637e27e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/ApacheHTTPClientTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
import org.junit.Test;
77

88
public class ApacheHTTPClientTest {
9+
static {
10+
try {
11+
// Since the HttpClientBuilder initializer doesn't work, invoke manually.
12+
Class.forName("com.datadoghq.agent.InstrumentationRulesManager")
13+
.getMethod("registerClassLoad", Object.class)
14+
.invoke(null, Thread.currentThread().getContextClassLoader());
15+
} catch (Exception e) {
16+
System.err.println("clinit error: " + e.getMessage());
17+
}
18+
}
919

1020
@Test
1121
public void test() throws Exception {
12-
// Since the HttpClientBuilder initializer doesn't work, invoke manually.
13-
Class.forName("com.datadoghq.agent.InstrumentationRulesManager")
14-
.getMethod("registerClassLoad")
15-
.invoke(null);
16-
1722
final HttpClientBuilder builder = HttpClientBuilder.create();
1823
assertThat(builder.getClass().getSimpleName()).isEqualTo("TracingHttpClientBuilder");
1924
}

0 commit comments

Comments
 (0)