Guard against invoking WeakConcurrent constructor
MODIFY
buildSrc/src/main/groovy/MuzzlePlugin.groovy
buildSrc/src/main/groovy/MuzzlePlugin.groovy
@@ -220,7 +220,6 @@ class MuzzlePlugin implements Plugin<Project> {
return inverseDirectives
}
-
/**
* Configure a muzzle task to pass or fail a given version.
*
@@ -315,6 +314,7 @@ class MuzzleDirective {
List<String> additionalDependencies = new ArrayList<>()
boolean assertPass
boolean assertInverse = false
+
void extraDependency(String compileString) {
additionalDependencies.add(compileString)
}

MODIFY
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/WeakMap.java
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/WeakMap.java
@@ -26,6 +26,10 @@ public interface WeakMap<K, V> {
}
}
+ public static boolean isProviderRegistered() {
+ return Provider.provider.get() != null;
+ }
+
public static <K, V> WeakMap<K, V> newWeakMap() {
return provider.get().get();
}

MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
@@ -98,7 +98,9 @@ public class AgentInstaller {
}
private static void registerWeakMapProvider() {
+ if (!WeakMap.Provider.isProviderRegistered()) {
WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent());
+ }
// WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent.Inline());
// WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.Guava());
}

Guard against invoking WeakConcurrent constructor