Skip to content

Commit

Permalink
More complete fix for #735
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 27, 2015
1 parent de5642e commit 7ff745c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
8 changes: 6 additions & 2 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ Project: jackson-databind
=== Releases ===
------------------------------------------------------------------------

2.4.6 (not yet released)

#735: (complete fix) @JsonDeserialize on Map with contentUsing custom deserializer overwrites default behavior
(reported by blackfyre512@github) (regression due to #604)

2.4.5.1 (26-Mar-2015)

Special one-off "micro patch" for:

#706: Add support for `@JsonUnwrapped` via JSON Schema module
#707: Error in getting string representation of an ObjectNode with a float number value
(reported by @navidqar)
#735: @JsonDeserialize on Map with contentUsing custom deserializer overwrites default behavior
(reported by blackfyre512@github) (regression due to #604)
#735: (partial) @JsonDeserialize on Map with contentUsing custom deserializer overwrites default behavior

2.4.5 (13-Jan-2015)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ protected JsonDeserializer<Object> _findCachedDeserializer(JavaType type)
if (type == null) {
throw new IllegalArgumentException("Null JavaType passed");
}
if (_hasCustomValueHandler(type)) {
return null;
}
return _cachedDeserializers.get(type);
}

Expand All @@ -214,7 +217,7 @@ protected JsonDeserializer<Object> _findCachedDeserializer(JavaType type)
* @param ctxt Currently active deserialization context
* @param type Type of property to deserialize
*/
protected JsonDeserializer<Object>_createAndCacheValueDeserializer(DeserializationContext ctxt,
protected JsonDeserializer<Object> _createAndCacheValueDeserializer(DeserializationContext ctxt,
DeserializerFactory factory, JavaType type)
throws JsonMappingException
{
Expand Down Expand Up @@ -273,7 +276,8 @@ protected JsonDeserializer<Object> _createAndCache2(DeserializationContext ctxt,
*/
// 08-Jun-2010, tatu: Related to [JACKSON-296], need to avoid caching MapSerializers... so:
boolean isResolvable = (deser instanceof ResolvableDeserializer);
boolean addToCache = deser.isCachable();
// 27-Mar-2015, tatu: As per [databind#735], avoid caching types with custom value desers
boolean addToCache = !_hasCustomValueHandler(type) && deser.isCachable();

/* we will temporarily hold on to all created deserializers (to
* handle cyclic references, and possibly reuse non-cached
Expand Down Expand Up @@ -538,6 +542,26 @@ private JavaType modifyTypeByAnnotation(DeserializationContext ctxt,
return type;
}

/*
/**********************************************************
/* Helper methods, other
/**********************************************************
*/

/**
* Helper method used to prevent both caching and cache lookups for structured
* types that have custom value handlers
*
* @since 2.4.6
*/
private boolean _hasCustomValueHandler(JavaType t) {
if (t.isContainerType()) {
JavaType ct = t.getContentType();
return (ct != null) && (ct.getValueHandler() != null);
}
return false;
}

private Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClass)
{
if (src == null) {
Expand All @@ -552,7 +576,7 @@ private Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClas
}
return cls;
}

/*
/**********************************************************
/* Overridable error reporting methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.math.BigInteger;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.io.NumberOutput;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.fasterxml.jackson.databind.deser;

import java.io.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;
import java.util.*;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.type.TypeReference;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package com.fasterxml.jackson.databind.deser;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.annotation.*;

import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
* Test for testing forward reference handling
Expand Down Expand Up @@ -67,7 +60,7 @@ public void setId(String id) {
}

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
private static class YetAnotherClass
static class YetAnotherClass
{
public YetAnotherClass() {}
public ForwardReferenceClass frc;
Expand Down

0 comments on commit 7ff745c

Please sign in to comment.