summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2022-11-01 10:21:58 +0100
committerGitHub <noreply@github.com>2022-11-01 10:21:58 +0100
commit7385bf58448a9e006486cd07bfb8701b201d82a5 (patch)
tree80f718b09546307bcc69df287d7c75b225f4f79a /vespajlib
parentf2fe167f4fdff5ed453773423d4b8a8aa36f3f78 (diff)
Apply suggestions from code review
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/MethodCache.java4
-rw-r--r--vespajlib/src/test/resources/dummy2
2 files changed, 5 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java b/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java
index 2b8f7831a20..700f16ee519 100644
--- a/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java
+++ b/vespajlib/src/main/java/com/yahoo/collections/MethodCache.java
@@ -36,6 +36,10 @@ public final class MethodCache {
public Method get(Object object, Consumer<String> onPut) {
Pair<Class<?>, Method> pair = cache.get(object.getClass().getName());
+ // When changing bundles, you might end up having cached the old method pointing to the old bundle.
+ // That will then lead to a class cast exception when invoking the wrong clone method.
+ // Whenever we detect a new class with the same name, we therefore drop the entire cache.
+ // This is also the reason for caching the pair of method and original class—not just the method.
if (pair != null && pair.getFirst() != object.getClass()) {
cache.clear();
pair = null;
diff --git a/vespajlib/src/test/resources/dummy b/vespajlib/src/test/resources/dummy
index 2995a4d0e74..421376db9e8 100644
--- a/vespajlib/src/test/resources/dummy
+++ b/vespajlib/src/test/resources/dummy
@@ -1 +1 @@
-dummy \ No newline at end of file
+dummy