Skip to content

Commit

Permalink
Fix #2016
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 4, 2018
1 parent bd0732c commit fbe64a2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 50 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -780,3 +780,7 @@ Jakub Skierbiszewski (jskierbi@github)
* Reported, contributed fix for #2001: Deserialization issue with `@JsonIgnore` and
`@JsonCreator` + `@JsonProperty` for same property name
(2.9.6)
Carter Kozak (cakofony@github)
* Reported #2016: Delegating JsonCreator disregards JsonDeserialize info
(2.9.6)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project: jackson-databind
#2001: Deserialization issue with `@JsonIgnore` and `@JsonCreator` + `@JsonProperty`
for same property name
(reported, fix contributed by Jakub S)
#2016: Delegating JsonCreator disregards JsonDeserialize info
(reported by Carter K)
#2019: Abstract Type mapping in 2.9 fails when multiple modules are registered
(reported by asger82@github)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ public ValueInstantiator findValueInstantiator(DeserializationContext ctxt,
if (instantiator.getIncompleteParameter() != null) {
final AnnotatedParameter nonAnnotatedParam = instantiator.getIncompleteParameter();
final AnnotatedWithParams ctor = nonAnnotatedParam.getOwner();
throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex()+" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator");
throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex()
+" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator");
}

return instantiator;
Expand Down Expand Up @@ -2143,36 +2144,6 @@ protected JavaType modifyTypeByAnnotation(DeserializationContext ctxt,
if (intr == null) {
return type;
}

// First, deserializers for key/value types?
/*
if (type.isMapLikeType()) {
JavaType keyType = type.getKeyType();
// 21-Mar-2011, tatu: ... and associated deserializer too (unless already assigned)
// (not 100% why or how, but this does seem to get called more than once, which
// is not good: for now, let's just avoid errors)
if (keyType != null && keyType.getValueHandler() == null) {
Object kdDef = intr.findKeyDeserializer(a);
KeyDeserializer kd = ctxt.keyDeserializerInstance(a, kdDef);
if (kd != null) {
type = (T) ((MapLikeType) type).withKeyValueHandler(kd);
keyType = type.getKeyType(); // just in case it's used below
}
}
}
JavaType contentType = type.getContentType();
if (contentType != null) {
// ... as well as deserializer for contents:
if (contentType.getValueHandler() == null) { // as with above, avoid resetting (which would trigger exception)
Object cdDef = intr.findContentDeserializer(a);
JsonDeserializer<?> cd = ctxt.deserializerInstance(a, cdDef);
if (cd != null) {
type = (T) type.withContentValueHandler(cd);
}
}
}
*/
// then: type refinement(s)?
return intr.refineDeserializationType(ctxt.getConfig(), a, type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public class CreatorCollector {

protected SettableBeanProperty[] _propertyBasedArgs;

protected AnnotatedParameter _incompleteParameter;

/*
/**********************************************************
/* Life-cycle
Expand All @@ -83,11 +81,12 @@ public CreatorCollector(BeanDescription beanDesc, MapperConfig<?> config) {
.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS);
}

public ValueInstantiator constructValueInstantiator(
DeserializationConfig config) {
final JavaType delegateType = _computeDelegateType(
public ValueInstantiator constructValueInstantiator(DeserializationConfig config)
throws JsonMappingException
{
final JavaType delegateType = _computeDelegateType(config,
_creators[C_DELEGATE], _delegateArgs);
final JavaType arrayDelegateType = _computeDelegateType(
final JavaType arrayDelegateType = _computeDelegateType(config,
_creators[C_ARRAY_DELEGATE], _arrayDelegateArgs);
final JavaType type = _beanDesc.getType();

Expand All @@ -108,7 +107,6 @@ public ValueInstantiator constructValueInstantiator(
inst.configureFromLongCreator(_creators[C_LONG]);
inst.configureFromDoubleCreator(_creators[C_DOUBLE]);
inst.configureFromBooleanCreator(_creators[C_BOOLEAN]);
inst.configureIncompleteParameter(_incompleteParameter);
return inst;
}

Expand Down Expand Up @@ -193,12 +191,6 @@ public void addPropertyCreator(AnnotatedWithParams creator,
}
}

public void addIncompeteParameter(AnnotatedParameter parameter) {
if (_incompleteParameter == null) {
_incompleteParameter = parameter;
}
}

/*
/**********************************************************
/* Accessors
Expand Down Expand Up @@ -232,8 +224,10 @@ public boolean hasPropertyBasedCreator() {
/**********************************************************
*/

private JavaType _computeDelegateType(AnnotatedWithParams creator,
SettableBeanProperty[] delegateArgs) {
private JavaType _computeDelegateType(MapperConfig<?> config,
AnnotatedWithParams creator, SettableBeanProperty[] delegateArgs)
throws JsonMappingException
{
if (!_hasNonDefaultCreator || (creator == null)) {
return null;
}
Expand All @@ -247,7 +241,11 @@ private JavaType _computeDelegateType(AnnotatedWithParams creator,
}
}
}
return creator.getParameterType(ix);
// 03-May-2018, tatu: [databind#2016] need to check possible annotation-based
// type refinement(s)
JavaType baseType = creator.getParameterType(ix);
return config.getAnnotationIntrospector().refineDeserializationType(config,
creator.getParameter(ix), baseType);
}

private <T extends AnnotatedMember> T _fixAccess(T member) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ protected JsonMappingException rewrapCtorProblem(DeserializationContext ctxt,
/**********************************************************
*/

private Object _createUsingDelegate(
AnnotatedWithParams delegateCreator,
private Object _createUsingDelegate(AnnotatedWithParams delegateCreator,
SettableBeanProperty[] delegateArguments,
DeserializationContext ctxt,
Object delegate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testTypeCompatibility1964() throws Exception
{
// Important! Must use raw type since assignment requires effectively
// casting due incompatible type parameters.
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
Map<String, Collection<String>> repoPrivilegesMap = new CustomMap();
String key = "/storages/storage0/releases";
Collection<String> values = new HashSet<>();
Expand Down

0 comments on commit fbe64a2

Please sign in to comment.