Skip to content

Commit

Permalink
Fixed #1297
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 15, 2016
1 parent 26f2669 commit db0eadb
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS
Expand Up @@ -509,3 +509,7 @@ Ari Fogel (arifogel@github)
Andriy Plokhotnyuk (plokhotnyuk@github) Andriy Plokhotnyuk (plokhotnyuk@github)
* Requested #1277: Add caching of resolved generic types for `TypeFactory` * Requested #1277: Add caching of resolved generic types for `TypeFactory`
(2.8.0) (2.8.0)

Arek Gabiga (arekgabiga@github)
* Reported #1297: Deserialization of generic type with Map.class
(2.8.1)
2 changes: 2 additions & 0 deletions release-notes/VERSION
Expand Up @@ -12,6 +12,8 @@ Project: jackson-databind
#1289: Optimize construction of `ArrayList`, `LinkedHashMap` instances #1289: Optimize construction of `ArrayList`, `LinkedHashMap` instances
#1291: Backward-incompatible behaviour of 2.8: deserializing enum types #1291: Backward-incompatible behaviour of 2.8: deserializing enum types
with two static factory methods fail by default with two static factory methods fail by default
#1297: Deserialization of generic type with Map.class
(reported by Arek G)


2.8.0 (04-Jul-2016) 2.8.0 (04-Jul-2016)


Expand Down
Expand Up @@ -441,8 +441,8 @@ public JavaType getParameterType(int index) {
return _base.getParameterType(index); return _base.getParameterType(index);
} }


@SuppressWarnings("deprecation")
@Override @Override
@Deprecated
public Type getGenericParameterType(int index) { public Type getGenericParameterType(int index) {
return _base.getGenericParameterType(index); return _base.getGenericParameterType(index);
} }
Expand Down
Expand Up @@ -281,7 +281,7 @@ public Class<?> findClass(String className) throws ClassNotFoundException
Throwable prob = null; Throwable prob = null;
ClassLoader loader = this.getClassLoader(); ClassLoader loader = this.getClassLoader();
if (loader == null) { if (loader == null) {
loader = Thread.currentThread().getContextClassLoader(); loader = Thread.currentThread().getContextClassLoader();
} }
if (loader != null) { if (loader != null) {
try { try {
Expand Down Expand Up @@ -1013,7 +1013,7 @@ private JavaType _mapType(Class<?> rawClass, TypeBindings bindings,
JavaType superClass, JavaType[] superInterfaces) JavaType superClass, JavaType[] superInterfaces)
{ {
JavaType kt, vt; JavaType kt, vt;

// 28-May-2015, tatu: Properties are special, as per [databind#810]; fake "correct" parameter sig // 28-May-2015, tatu: Properties are special, as per [databind#810]; fake "correct" parameter sig
if (rawClass == Properties.class) { if (rawClass == Properties.class) {
kt = vt = CORE_TYPE_STRING; kt = vt = CORE_TYPE_STRING;
Expand Down Expand Up @@ -1307,6 +1307,10 @@ protected JavaType[] _resolveSuperInterfaces(ClassStack context, Class<?> rawTyp
protected JavaType _fromWellKnownClass(ClassStack context, Class<?> rawType, TypeBindings bindings, protected JavaType _fromWellKnownClass(ClassStack context, Class<?> rawType, TypeBindings bindings,
JavaType superClass, JavaType[] superInterfaces) JavaType superClass, JavaType[] superInterfaces)
{ {
if (bindings == null) {
bindings = TypeBindings.emptyBindings();
}

// Quite simple when we resolving exact class/interface; start with that // Quite simple when we resolving exact class/interface; start with that
if (rawType == Map.class) { if (rawType == Map.class) {
return _mapType(rawType, bindings, superClass, superInterfaces); return _mapType(rawType, bindings, superClass, superInterfaces);
Expand Down

This file was deleted.

Expand Up @@ -5,7 +5,7 @@
/** /**
* Failing test related to [databind#609] * Failing test related to [databind#609]
*/ */
public class TestLocalType609 extends BaseMapTest public class TestLocalTypes extends BaseMapTest
{ {
static class EntityContainer { static class EntityContainer {
RuleForm entity; RuleForm entity;
Expand Down
Expand Up @@ -29,14 +29,17 @@ public Set<java.util.Map.Entry<K, Collection<V>>> entrySet() {
} }
} }
} }


// for [databind#76]
@SuppressWarnings("serial")
static class HashTree<K, V> extends HashMap<K, HashTree<K, V>> { }

/* /*
/********************************************************** /**********************************************************
/* Test methods /* Test methods
/********************************************************** /**********************************************************
*/ */


// [JACKSON-677]
public void testInnerType() throws Exception public void testInnerType() throws Exception
{ {
TypeFactory tf = TypeFactory.defaultInstance(); TypeFactory tf = TypeFactory.defaultInstance();
Expand All @@ -49,4 +52,12 @@ public void testInnerType() throws Exception
JavaType vt2 = valueType.getContentType(); JavaType vt2 = valueType.getContentType();
assertEquals(Object.class, vt2.getRawClass()); assertEquals(Object.class, vt2.getRawClass());
} }

// for [databind#76]
public void testRecursiveType()
{
TypeFactory tf = TypeFactory.defaultInstance();
JavaType type = tf.constructType(HashTree.class);
assertNotNull(type);
}
} }
Expand Up @@ -70,7 +70,11 @@ static class StringListBean {


static class CollectionLike<E> { } static class CollectionLike<E> { }
static class MapLike<K,V> { } static class MapLike<K,V> { }


static class Wrapper1297<T> {
public T content;
}

/* /*
/********************************************************** /**********************************************************
/* Unit tests /* Unit tests
Expand Down Expand Up @@ -565,5 +569,14 @@ public void testCacheClearing()
tf.clearCache(); tf.clearCache();
assertEquals(0, tf._typeCache.size()); assertEquals(0, tf._typeCache.size());
} }

// for [databind#1297]
public void testRawMapType()
{
TypeFactory tf = TypeFactory.defaultInstance().withModifier(null); // to get a new copy

JavaType type = tf.constructParametricType(Wrapper1297.class, Map.class);
assertNotNull(type);
assertEquals(Wrapper1297.class, type.getRawClass());
}
} }

0 comments on commit db0eadb

Please sign in to comment.