Fix WeakConcurrentMap memory leak
MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/cache/internal/weaklockfree/WeakConcurrentMap.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/cache/internal/weaklockfree/WeakConcurrentMap.java
@@ -215,6 +215,12 @@ public class WeakConcurrentMap<K, V>
return super.get(key);
}
+ @Override
+ public V getIfPresent(K key) {
+ expungeStaleEntries();
+ return super.getIfPresent(key);
+ }
+
@Override
public boolean containsKey(K key) {
expungeStaleEntries();
@@ -227,6 +233,12 @@ public class WeakConcurrentMap<K, V>
return super.put(key, value);
}
+ @Override
+ public V putIfAbsent(K key, V value) {
+ expungeStaleEntries();
+ return super.putIfAbsent(key, value);
+ }
+
@Override
public V remove(K key) {
expungeStaleEntries();

Fix WeakConcurrentMap memory leak (#5316)