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

DELETE
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Cleaner.java
-package datadog.trace.agent.tooling;
-
-import datadog.common.exec.CommonTaskExecutor;
-import datadog.common.exec.CommonTaskExecutor.Task;
-import java.util.concurrent.TimeUnit;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-class Cleaner {
-
- <T> void scheduleCleaning(
- final T target, final Adapter<T> adapter, final long frequency, final TimeUnit unit) {
- CommonTaskExecutor.INSTANCE.scheduleAtFixedRate(
- new CleaningTask(adapter), target, frequency, frequency, unit, "cleaner for " + target);
- }
-
- // Important to use explicit class to avoid implicit hard references to target
- private static class CleaningTask<T> implements Task<T> {
- private final Adapter<T> adapter;
-
- public CleaningTask(final Adapter<T> adapter) {
- this.adapter = adapter;
- }
-
- @Override
- public void run(final T target) {
- adapter.clean(target);
- }
- }
-
- public interface Adapter<T> {
- void clean(T target);
- }
-}

MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/WeakMapSuppliers.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/WeakMapSuppliers.java
@@ -33,11 +33,6 @@ class WeakMapSuppliers {
static class WeakConcurrent implements WeakMap.Implementation {
@VisibleForTesting static final long CLEAN_FREQUENCY_SECONDS = 1;
- private final Cleaner cleaner;
-
- WeakConcurrent(final Cleaner cleaner) {
- this.cleaner = cleaner;
- }
@Override
public <K, V> WeakMap<K, V> get() {

MODIFY
dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/WeakConcurrentSupplierTest.groovy
dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/WeakConcurrentSupplierTest.groovy
@@ -13,9 +13,7 @@ import java.util.concurrent.TimeUnit
// These tests fail sometimes in CI.
class WeakConcurrentSupplierTest extends DDSpecification {
@Shared
- def cleaner = new Cleaner()
- @Shared
- def weakConcurrentSupplier = new WeakMapSuppliers.WeakConcurrent(cleaner)
+ def weakConcurrentSupplier = new WeakMapSuppliers.WeakConcurrent()
@Shared
def weakInlineSupplier = new WeakMapSuppliers.WeakConcurrent.Inline()
@Shared

Remove Cleaner class