Skip to content

Commit 3470803

Browse files
committed
Backport #761 fix in 2.5(.3)
1 parent ae10786 commit 3470803

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

release-notes/CREDITS

+5
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ Dylan Scott (dylanscott@github)
221221
issue)
222222
(2.5.2)
223223

224+
Alexey Gavrilov (Alexey1Gavrilov@github)
225+
* Reported, contributed fix for #761: Builder deserializer: in-compatible type exception
226+
when return type is super type
227+
(2.5.3)
228+
224229
Dmitry Spikhalskiy (Spikhalskiy@github)
225230
* Reported #731, suggested the way to fix it: XmlAdapter result marshaling error in
226231
case of ValueType=Object

release-notes/VERSION

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Project: jackson-databind
1313
(reported by migel@github)
1414
#745: EnumDeserializer.deserializerForCreator fails when used to deserialize a Map key
1515
(contributed by John M)
16+
#761: Builder deserializer: in-compatible type exception when return type is super type
17+
(contributed by Alexey G)
1618

1719
2.5.2 (29-Mar-2015)
1820

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,13 @@ public JsonDeserializer<?> buildBuilderBased(JavaType valueType,
374374
}
375375
// also: type of the method must be compatible
376376
Class<?> rawBuildType = _buildMethod.getRawReturnType();
377-
if (!valueType.getRawClass().isAssignableFrom(rawBuildType)) {
377+
Class<?> rawValueType = valueType.getRawClass();
378+
if ((rawBuildType != rawValueType)
379+
&& !rawBuildType.isAssignableFrom(rawValueType)
380+
&& !rawValueType.isAssignableFrom(rawBuildType)) {
378381
throw new IllegalArgumentException("Build method '"+_buildMethod.getFullName()
379-
+" has bad return type ("+rawBuildType.getName()
380-
+"), not compatible with POJO type ("+valueType.getRawClass().getName()+")");
382+
+" has bad return type ("+rawBuildType.getName()
383+
+"), not compatible with POJO type ("+valueType.getRawClass().getName()+")");
381384
}
382385
// And if so, we can try building the deserializer
383386
Collection<SettableBeanProperty> props = _properties.values();

0 commit comments

Comments
 (0)