From 11b1323ebb7ccd52e7ac52d76ab8d7b76290d253 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 16 Jul 2016 16:57:34 -0700 Subject: [PATCH] Fixed #1302 --- release-notes/VERSION | 1 + .../jackson/databind/type/ResolvedRecursiveType.java | 9 ++++++--- .../com/fasterxml/jackson/databind/type/SimpleType.java | 2 +- .../com/fasterxml/jackson/databind/type/TypeFactory.java | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index 84e73058d9..a90e0a73ed 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -14,6 +14,7 @@ Project: jackson-databind with two static factory methods fail by default #1297: Deserialization of generic type with Map.class (reported by Arek G) +#1302: NPE for `ResolvedRecursiveType` in 2.8.0 due to caching 2.8.0 (04-Jul-2016) diff --git a/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java b/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java index d5cbac3fb0..6c671b31ac 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java @@ -98,8 +98,11 @@ public String toString() { public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; - if (o.getClass() != getClass()) return false; - - return ((ResolvedRecursiveType) o).getSelfReferencedType().equals(getSelfReferencedType()); + // Do NOT ever match unresolved references + if (_referencedType == null) { + return false; + } + return (o.getClass() == getClass() + && _referencedType.equals(((ResolvedRecursiveType) o).getSelfReferencedType())); } } diff --git a/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java b/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java index ee0984df84..c48c0f3398 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java @@ -128,7 +128,7 @@ protected JavaType _narrow(Class subclass) // Should we check that there is a sub-class relationship? // 15-Jan-2016, tatu: Almost yes, but there are some complications with // placeholder values (`Void`, `NoClass`), so can not quite do yet. - // TODO: fix in 2.8 + // TODO: fix in 2.9 if (!_class.isAssignableFrom(subclass)) { /* throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of " diff --git a/src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java b/src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java index 219b774a7c..9f62740bdf 100644 --- a/src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java @@ -1269,6 +1269,8 @@ else if (superClass != null) { } } context.resolveSelfReferences(result); + // 16-Jul-2016, tatu: [databind#1302] is solved different way, but ideally we shouldn't + // cache anything with partially resolved `ResolvedRecursiveType`... so maybe improve if (!result.hasHandlers()) { _typeCache.putIfAbsent(key, result); // cache object syncs }