diff --git a/newrelic-security-agent/src/main/java/com/newrelic/agent/security/intcodeagent/utils/TTLMap.java b/newrelic-security-agent/src/main/java/com/newrelic/agent/security/intcodeagent/utils/TTLMap.java index 3cd3bb70f..1a49e0418 100644 --- a/newrelic-security-agent/src/main/java/com/newrelic/agent/security/intcodeagent/utils/TTLMap.java +++ b/newrelic-security-agent/src/main/java/com/newrelic/agent/security/intcodeagent/utils/TTLMap.java @@ -3,6 +3,7 @@ import com.newrelic.agent.security.intcodeagent.schedulers.SchedulerHelper; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; public class TTLMap { @@ -18,6 +19,7 @@ public TTLMap(String id) { public TTLMap(String id, long ttl) { this.id = id; TTL = ttl; + SchedulerHelper.getInstance().scheduleTTLMapCleanup(this::removeExpiredEntries, ttl, ttl, TimeUnit.MILLISECONDS, id); } public void put(K key, V value) { @@ -48,7 +50,7 @@ public void shutdown() { SchedulerHelper.getInstance().cancelTTLMapCleanup(this.id); } - public boolean containsKey(K traceId) { - return map.containsKey(traceId); - } + public boolean containsKey(K traceId) { + return map.containsKey(traceId); + } }