Put back muzzle check for 'dd-' threads
MODIFY
buildSrc/src/main/groovy/MuzzlePlugin.groovy
buildSrc/src/main/groovy/MuzzlePlugin.groovy
@@ -15,6 +15,7 @@ import org.eclipse.aether.spi.connector.transport.TransporterFactory
import org.eclipse.aether.transport.http.HttpTransporterFactory
import org.eclipse.aether.version.Version
import org.gradle.api.Action
+import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
@@ -278,6 +279,12 @@ class MuzzlePlugin implements Plugin<Project> {
Method assertionMethod = instrumentationCL.loadClass('datadog.trace.agent.tooling.muzzle.MuzzleVersionScanPlugin')
.getMethod('assertInstrumentationMuzzled', ClassLoader.class, ClassLoader.class, boolean.class)
assertionMethod.invoke(null, instrumentationCL, userCL, muzzleDirective.assertPass)
+
+ for (Thread thread : Thread.getThreads()) {
+ if (thread.getName().startsWith("dd-")) {
+ throw new GradleException("Task $taskName has spawned a thread: $thread. This will prevent GC of dynamic muzzle classes. Aborting muzzle run.")
+ }
+ }
}
}
runAfter.finalizedBy(muzzleTask)

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
@@ -29,6 +29,10 @@ public interface WeakMap<K, V> {
}
}
+ public static boolean isProviderRegistered() {
+ return provider.get() != Supplier.DEFAULT;
+ }
+
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
@@ -111,7 +111,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());
}

Put back muzzle check for 'dd-' threads