Fix muzzle
This commit is contained in:
parent
75c7769192
commit
e5980d4812
|
@ -135,7 +135,6 @@ class MuzzlePlugin implements Plugin<Project> {
|
|||
}
|
||||
def loader = new URLClassLoader(ddUrls.toArray(new URL[0]), (ClassLoader) null)
|
||||
assert TOOLING_LOADER.compareAndSet(null, loader)
|
||||
loader.loadClass("datadog.trace.agent.tooling.AgentTooling").getMethod("init").invoke(null)
|
||||
return TOOLING_LOADER.get()
|
||||
} else {
|
||||
return toolingLoader
|
||||
|
@ -293,7 +292,9 @@ class MuzzlePlugin implements Plugin<Project> {
|
|||
def ccl = Thread.currentThread().contextClassLoader
|
||||
def bogusLoader = new SecureClassLoader() {
|
||||
@Override
|
||||
String toString() { return "bogus" }
|
||||
String toString() {
|
||||
return "bogus"
|
||||
}
|
||||
}
|
||||
Thread.currentThread().contextClassLoader = bogusLoader
|
||||
final ClassLoader userCL = createClassLoaderForTask(instrumentationProject, bootstrapProject, taskName)
|
||||
|
|
|
@ -8,20 +8,15 @@ import datadog.trace.bootstrap.WeakMap;
|
|||
* logic out.
|
||||
*/
|
||||
public class AgentTooling {
|
||||
private static final Cleaner CLEANER = new Cleaner();
|
||||
|
||||
static {
|
||||
// WeakMap is used by other classes below, so we need to register the provider first.
|
||||
registerWeakMapProvider(CLEANER);
|
||||
registerWeakMapProvider();
|
||||
}
|
||||
|
||||
private static final DDLocationStrategy LOCATION_STRATEGY = new DDLocationStrategy();
|
||||
private static final DDCachingPoolStrategy POOL_STRATEGY = new DDCachingPoolStrategy();
|
||||
|
||||
public static void init() {
|
||||
// Only need to trigger static initializers for now.
|
||||
}
|
||||
|
||||
public static DDLocationStrategy locationStrategy() {
|
||||
return LOCATION_STRATEGY;
|
||||
}
|
||||
|
@ -30,9 +25,9 @@ public class AgentTooling {
|
|||
return POOL_STRATEGY;
|
||||
}
|
||||
|
||||
private static void registerWeakMapProvider(final Cleaner cleaner) {
|
||||
private static void registerWeakMapProvider() {
|
||||
if (!WeakMap.Provider.isProviderRegistered()) {
|
||||
WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent(cleaner));
|
||||
WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent(new Cleaner()));
|
||||
// WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.WeakConcurrent.Inline());
|
||||
// WeakMap.Provider.registerIfAbsent(new WeakMapSuppliers.Guava());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package datadog.trace.agent.tooling.muzzle;
|
||||
|
||||
import datadog.trace.agent.tooling.AgentTooling;
|
||||
import datadog.trace.agent.tooling.HelperInjector;
|
||||
import datadog.trace.agent.tooling.Instrumenter;
|
||||
import java.io.IOException;
|
||||
|
@ -20,9 +19,6 @@ import net.bytebuddy.dynamic.ClassFileLocator;
|
|||
* <p>Additionally, after a successful muzzle validation run each instrumenter's helper injector.
|
||||
*/
|
||||
public class MuzzleVersionScanPlugin {
|
||||
static {
|
||||
AgentTooling.init();
|
||||
}
|
||||
|
||||
public static void assertInstrumentationMuzzled(
|
||||
final ClassLoader instrumentationLoader,
|
||||
|
|
|
@ -9,13 +9,13 @@ import spock.lang.Shared
|
|||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import static datadog.trace.agent.tooling.AgentTooling.CLEANER
|
||||
|
||||
@Retry
|
||||
// These tests fail sometimes in CI.
|
||||
class WeakConcurrentSupplierTest extends DDSpecification {
|
||||
@Shared
|
||||
def weakConcurrentSupplier = new WeakMapSuppliers.WeakConcurrent(CLEANER)
|
||||
def cleaner = new Cleaner()
|
||||
@Shared
|
||||
def weakConcurrentSupplier = new WeakMapSuppliers.WeakConcurrent(cleaner)
|
||||
@Shared
|
||||
def weakInlineSupplier = new WeakMapSuppliers.WeakConcurrent.Inline()
|
||||
@Shared
|
||||
|
@ -59,7 +59,7 @@ class WeakConcurrentSupplierTest extends DDSpecification {
|
|||
|
||||
where:
|
||||
name | supplierSupplier
|
||||
"WeakConcurrent" | { -> new WeakMapSuppliers.WeakConcurrent(CLEANER) }
|
||||
"WeakConcurrent" | { -> new WeakMapSuppliers.WeakConcurrent(cleaner) }
|
||||
"WeakInline" | { -> new WeakMapSuppliers.WeakConcurrent.Inline() }
|
||||
"Guava" | { -> new WeakMapSuppliers.Guava() }
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public final class DaemonThreadFactory implements ThreadFactory {
|
|||
private final String threadName;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code DaemonThreadFactory}.
|
||||
* Constructs a new {@code DaemonThreadFactory} with a null ContextClassLoader.
|
||||
*
|
||||
* @param threadName used to prefix all thread names.
|
||||
*/
|
||||
|
@ -25,6 +25,7 @@ public final class DaemonThreadFactory implements ThreadFactory {
|
|||
public Thread newThread(final Runnable r) {
|
||||
final Thread thread = new Thread(r, threadName);
|
||||
thread.setDaemon(true);
|
||||
thread.setContextClassLoader(null);
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue