Skip to content

Commit f9f0438

Browse files
committed
Initialize WeakMapProvider even earlier
It is used by classes delcared as static fields in AgentInstaller, so there were some cases where the fallback is being used.
1 parent 70e4525 commit f9f0438

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
@Slf4j
2222
public class AgentInstaller {
23+
static {
24+
// WeakMap is used by other classes below, so we need to register the provider first.
25+
registerWeakMapProvider();
26+
}
27+
2328
public static final DDLocationStrategy LOCATION_STRATEGY = new DDLocationStrategy();
2429
public static final AgentBuilder.PoolStrategy POOL_STRATEGY = new DDCachingPoolStrategy();
2530
private static volatile Instrumentation INSTRUMENTATION;
@@ -41,7 +46,6 @@ public static ResettableClassFileTransformer installBytebuddyAgent(final Instrum
4146
public static ResettableClassFileTransformer installBytebuddyAgent(
4247
final Instrumentation inst, final AgentBuilder.Listener... listeners) {
4348
INSTRUMENTATION = inst;
44-
registerWeakMapProvider();
4549

4650
AgentBuilder agentBuilder =
4751
new AgentBuilder.Default()

0 commit comments

Comments
 (0)