Skip to content

Commit fbe64a2

Browse files
committed
Fix #2016
1 parent bd0732c commit fbe64a2

File tree

6 files changed

+24
-50
lines changed

6 files changed

+24
-50
lines changed

release-notes/CREDITS-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,3 +780,7 @@ Jakub Skierbiszewski (jskierbi@github)
780780
* Reported, contributed fix for #2001: Deserialization issue with `@JsonIgnore` and
781781
`@JsonCreator` + `@JsonProperty` for same property name
782782
(2.9.6)
783+
784+
Carter Kozak (cakofony@github)
785+
* Reported #2016: Delegating JsonCreator disregards JsonDeserialize info
786+
(2.9.6)

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Project: jackson-databind
2121
#2001: Deserialization issue with `@JsonIgnore` and `@JsonCreator` + `@JsonProperty`
2222
for same property name
2323
(reported, fix contributed by Jakub S)
24+
#2016: Delegating JsonCreator disregards JsonDeserialize info
25+
(reported by Carter K)
2426
#2019: Abstract Type mapping in 2.9 fails when multiple modules are registered
2527
(reported by asger82@github)
2628

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

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ public ValueInstantiator findValueInstantiator(DeserializationContext ctxt,
275275
if (instantiator.getIncompleteParameter() != null) {
276276
final AnnotatedParameter nonAnnotatedParam = instantiator.getIncompleteParameter();
277277
final AnnotatedWithParams ctor = nonAnnotatedParam.getOwner();
278-
throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex()+" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator");
278+
throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex()
279+
+" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator");
279280
}
280281

281282
return instantiator;
@@ -2143,36 +2144,6 @@ protected JavaType modifyTypeByAnnotation(DeserializationContext ctxt,
21432144
if (intr == null) {
21442145
return type;
21452146
}
2146-
2147-
// First, deserializers for key/value types?
2148-
/*
2149-
if (type.isMapLikeType()) {
2150-
JavaType keyType = type.getKeyType();
2151-
// 21-Mar-2011, tatu: ... and associated deserializer too (unless already assigned)
2152-
// (not 100% why or how, but this does seem to get called more than once, which
2153-
// is not good: for now, let's just avoid errors)
2154-
if (keyType != null && keyType.getValueHandler() == null) {
2155-
Object kdDef = intr.findKeyDeserializer(a);
2156-
KeyDeserializer kd = ctxt.keyDeserializerInstance(a, kdDef);
2157-
if (kd != null) {
2158-
type = (T) ((MapLikeType) type).withKeyValueHandler(kd);
2159-
keyType = type.getKeyType(); // just in case it's used below
2160-
}
2161-
}
2162-
}
2163-
JavaType contentType = type.getContentType();
2164-
if (contentType != null) {
2165-
// ... as well as deserializer for contents:
2166-
if (contentType.getValueHandler() == null) { // as with above, avoid resetting (which would trigger exception)
2167-
Object cdDef = intr.findContentDeserializer(a);
2168-
JsonDeserializer<?> cd = ctxt.deserializerInstance(a, cdDef);
2169-
if (cd != null) {
2170-
type = (T) type.withContentValueHandler(cd);
2171-
}
2172-
}
2173-
}
2174-
*/
2175-
// then: type refinement(s)?
21762147
return intr.refineDeserializationType(ctxt.getConfig(), a, type);
21772148
}
21782149

src/main/java/com/fasterxml/jackson/databind/deser/impl/CreatorCollector.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public class CreatorCollector {
6868

6969
protected SettableBeanProperty[] _propertyBasedArgs;
7070

71-
protected AnnotatedParameter _incompleteParameter;
72-
7371
/*
7472
/**********************************************************
7573
/* Life-cycle
@@ -83,11 +81,12 @@ public CreatorCollector(BeanDescription beanDesc, MapperConfig<?> config) {
8381
.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS);
8482
}
8583

86-
public ValueInstantiator constructValueInstantiator(
87-
DeserializationConfig config) {
88-
final JavaType delegateType = _computeDelegateType(
84+
public ValueInstantiator constructValueInstantiator(DeserializationConfig config)
85+
throws JsonMappingException
86+
{
87+
final JavaType delegateType = _computeDelegateType(config,
8988
_creators[C_DELEGATE], _delegateArgs);
90-
final JavaType arrayDelegateType = _computeDelegateType(
89+
final JavaType arrayDelegateType = _computeDelegateType(config,
9190
_creators[C_ARRAY_DELEGATE], _arrayDelegateArgs);
9291
final JavaType type = _beanDesc.getType();
9392

@@ -108,7 +107,6 @@ public ValueInstantiator constructValueInstantiator(
108107
inst.configureFromLongCreator(_creators[C_LONG]);
109108
inst.configureFromDoubleCreator(_creators[C_DOUBLE]);
110109
inst.configureFromBooleanCreator(_creators[C_BOOLEAN]);
111-
inst.configureIncompleteParameter(_incompleteParameter);
112110
return inst;
113111
}
114112

@@ -193,12 +191,6 @@ public void addPropertyCreator(AnnotatedWithParams creator,
193191
}
194192
}
195193

196-
public void addIncompeteParameter(AnnotatedParameter parameter) {
197-
if (_incompleteParameter == null) {
198-
_incompleteParameter = parameter;
199-
}
200-
}
201-
202194
/*
203195
/**********************************************************
204196
/* Accessors
@@ -232,8 +224,10 @@ public boolean hasPropertyBasedCreator() {
232224
/**********************************************************
233225
*/
234226

235-
private JavaType _computeDelegateType(AnnotatedWithParams creator,
236-
SettableBeanProperty[] delegateArgs) {
227+
private JavaType _computeDelegateType(MapperConfig<?> config,
228+
AnnotatedWithParams creator, SettableBeanProperty[] delegateArgs)
229+
throws JsonMappingException
230+
{
237231
if (!_hasNonDefaultCreator || (creator == null)) {
238232
return null;
239233
}
@@ -247,7 +241,11 @@ private JavaType _computeDelegateType(AnnotatedWithParams creator,
247241
}
248242
}
249243
}
250-
return creator.getParameterType(ix);
244+
// 03-May-2018, tatu: [databind#2016] need to check possible annotation-based
245+
// type refinement(s)
246+
JavaType baseType = creator.getParameterType(ix);
247+
return config.getAnnotationIntrospector().refineDeserializationType(config,
248+
creator.getParameter(ix), baseType);
251249
}
252250

253251
private <T extends AnnotatedMember> T _fixAccess(T member) {

src/main/java/com/fasterxml/jackson/databind/deser/std/StdValueInstantiator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,7 @@ protected JsonMappingException rewrapCtorProblem(DeserializationContext ctxt,
509509
/**********************************************************
510510
*/
511511

512-
private Object _createUsingDelegate(
513-
AnnotatedWithParams delegateCreator,
512+
private Object _createUsingDelegate(AnnotatedWithParams delegateCreator,
514513
SettableBeanProperty[] delegateArguments,
515514
DeserializationContext ctxt,
516515
Object delegate)

src/test/java/com/fasterxml/jackson/databind/jsontype/SubTypeResolution1964Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void testTypeCompatibility1964() throws Exception
3939
{
4040
// Important! Must use raw type since assignment requires effectively
4141
// casting due incompatible type parameters.
42-
@SuppressWarnings("unchecked")
42+
@SuppressWarnings({ "unchecked", "rawtypes" })
4343
Map<String, Collection<String>> repoPrivilegesMap = new CustomMap();
4444
String key = "/storages/storage0/releases";
4545
Collection<String> values = new HashSet<>();

0 commit comments

Comments
 (0)