diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-10-25 18:49:16 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-10-25 18:51:54 +0200 |
commit | 682edac3e385154e0ce22ce0a502d8ab7d9c6c6a (patch) | |
tree | b160da2329c1c68e5dd5169a4de694210097e038 /vespajlib/src | |
parent | e899053702569af8205d49c7fa5391bfbe6481b5 (diff) |
Add a hook for tracking inserts into the method cache and log whenever clone methods are added.
Diffstat (limited to 'vespajlib/src')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/collections/MethodCache.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java b/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java index 4a4331b1c6e..bf9200efb2e 100644 --- a/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java +++ b/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java @@ -4,6 +4,7 @@ package com.yahoo.collections; import com.yahoo.concurrent.CopyOnWriteHashMap; import java.lang.reflect.Method; +import java.util.function.Consumer; /** * This will cache methods solved by reflection as reflection is expensive. @@ -28,11 +29,17 @@ public final class MethodCache { public void clear() { cache.clear(); } + public Method get(Object object) { + return get(object, null); + } + public Method get(Object object, Consumer<String> onPut) { Method m = cache.get(object.getClass().getName()); if (m == null) { m = lookupMethod(object); if (m != null) { + if (onPut != null) + onPut.accept(object.getClass().getName()); cache.put(object.getClass().getName(), m); } } |