diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
index 3f0280db1b..d13836794a 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
@@ -76,10 +76,13 @@ public class JacksonAnnotationIntrospector
* need for actual meta-annotation introspection.
*
* Non-final only because it needs to be re-created after deserialization.
+ *
+ * Starting with 2.15 key is {@link String} (before that was {@link Class})
+ * to avoid unintentional retention of third-party annotation class types.
*
* @since 2.7
*/
- protected transient LRUMap,Boolean> _annotationsInside = new LRUMap,Boolean>(48, 48);
+ protected transient LRUMap _annotationsInside = new LRUMap(48, 48);
/*
/**********************************************************
@@ -112,7 +115,7 @@ public Version version() {
protected Object readResolve() {
if (_annotationsInside == null) {
- _annotationsInside = new LRUMap,Boolean>(48, 48);
+ _annotationsInside = new LRUMap<>(48, 48);
}
return this;
}
@@ -155,11 +158,12 @@ public boolean isAnnotationBundle(Annotation ann) {
// mostly in degenerate cases where introspection used more often than
// it should (like recreating ObjectMapper once per read/write).
// But it may be more beneficial on platforms like Android (should verify)
- Class> type = ann.annotationType();
- Boolean b = _annotationsInside.get(type);
+ final Class> type = ann.annotationType();
+ final String typeName = type.getName();
+ Boolean b = _annotationsInside.get(typeName);
if (b == null) {
b = type.getAnnotation(JacksonAnnotationsInside.class) != null;
- _annotationsInside.putIfAbsent(type, b);
+ _annotationsInside.putIfAbsent(typeName, b);
}
return b.booleanValue();
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/util/LRUMap.java b/src/main/java/com/fasterxml/jackson/databind/util/LRUMap.java
index 78752544c6..f8428ce8cc 100644
--- a/src/main/java/com/fasterxml/jackson/databind/util/LRUMap.java
+++ b/src/main/java/com/fasterxml/jackson/databind/util/LRUMap.java
@@ -12,11 +12,16 @@
* on assumption that all use cases are for caching where persistence
* does not make sense. The only thing serialized is the cache size of Map.
*
- * NOTE: since Jackson 2.14, the implementation evicts the least recently used
- * entry when max size is reached.
- *
* Since Jackson 2.12, there has been pluggable {@link LookupCache} interface which
* allows users, frameworks, provide their own cache implementations.
+ *
+ * Snce Jackson 2.14, the implementation
+ *
+ *- Evicts the least recently used entry when max size is reached
+ *
+ *- Is thread-safe and does NOT require external synchronization
+ *
+ *
*/
public class LRUMap
implements LookupCache, // since 2.12