Skip to content

Commit 11b1323

Browse files
committed
Fixed #1302
1 parent 2d2f0c7 commit 11b1323

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

release-notes/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Project: jackson-databind
1414
with two static factory methods fail by default
1515
#1297: Deserialization of generic type with Map.class
1616
(reported by Arek G)
17+
#1302: NPE for `ResolvedRecursiveType` in 2.8.0 due to caching
1718

1819
2.8.0 (04-Jul-2016)
1920

src/main/java/com/fasterxml/jackson/databind/type/ResolvedRecursiveType.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ public String toString() {
9898
public boolean equals(Object o) {
9999
if (o == this) return true;
100100
if (o == null) return false;
101-
if (o.getClass() != getClass()) return false;
102-
103-
return ((ResolvedRecursiveType) o).getSelfReferencedType().equals(getSelfReferencedType());
101+
// Do NOT ever match unresolved references
102+
if (_referencedType == null) {
103+
return false;
104+
}
105+
return (o.getClass() == getClass()
106+
&& _referencedType.equals(((ResolvedRecursiveType) o).getSelfReferencedType()));
104107
}
105108
}

src/main/java/com/fasterxml/jackson/databind/type/SimpleType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected JavaType _narrow(Class<?> subclass)
128128
// Should we check that there is a sub-class relationship?
129129
// 15-Jan-2016, tatu: Almost yes, but there are some complications with
130130
// placeholder values (`Void`, `NoClass`), so can not quite do yet.
131-
// TODO: fix in 2.8
131+
// TODO: fix in 2.9
132132
if (!_class.isAssignableFrom(subclass)) {
133133
/*
134134
throw new IllegalArgumentException("Class "+subclass.getName()+" not sub-type of "

src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java

+2
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,8 @@ else if (superClass != null) {
12691269
}
12701270
}
12711271
context.resolveSelfReferences(result);
1272+
// 16-Jul-2016, tatu: [databind#1302] is solved different way, but ideally we shouldn't
1273+
// cache anything with partially resolved `ResolvedRecursiveType`... so maybe improve
12721274
if (!result.hasHandlers()) {
12731275
_typeCache.putIfAbsent(key, result); // cache object syncs
12741276
}

0 commit comments

Comments
 (0)