Skip to content

Commit f92a6b3

Browse files
committed
Merge branch '2.4' into 2.5
Conflicts: release-notes/VERSION
2 parents 3da7c45 + a143c05 commit f92a6b3

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ public boolean useForType(JavaType t)
173173
}
174174
// fall through
175175
case OBJECT_AND_NON_CONCRETE:
176-
return (t.getRawClass() == Object.class) || !t.isConcrete()
177-
// [Issue#88] Should not apply to JSON tree models:
178-
|| TreeNode.class.isAssignableFrom(t.getRawClass());
176+
return t.isJavaLangObject()
177+
|| (!t.isConcrete()
178+
// [databind#88] Should not apply to JSON tree models:
179+
&& !TreeNode.class.isAssignableFrom(t.getRawClass()));
180+
179181
case NON_FINAL:
180182
while (t.isArrayType()) {
181183
t = t.getContentType();
@@ -184,7 +186,7 @@ public boolean useForType(JavaType t)
184186
return !t.isFinal() && !TreeNode.class.isAssignableFrom(t.getRawClass());
185187
default:
186188
//case JAVA_LANG_OBJECT:
187-
return (t.getRawClass() == Object.class);
189+
return t.isJavaLangObject();
188190
}
189191
}
190192
}

src/test/java/com/fasterxml/jackson/databind/node/TestJsonNode.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public void testBinary() throws Exception
8585
assertEquals("\"Aw==\"", n.toString());
8686

8787
assertEquals("AAMD", new BinaryNode(data).asText());
88-
89-
// 1.6:
9088
assertNodeNumbersForNonNumeric(n);
9189
}
9290

@@ -101,10 +99,25 @@ public void testPOJO()
10199

102100
assertEquals(new POJONode(null), new POJONode(null));
103101

104-
// 1.6:
105102
// default; non-numeric
106103
assertNodeNumbersForNonNumeric(n);
107104
// but if wrapping actual number, use it
108105
assertNodeNumbers(new POJONode(Integer.valueOf(123)), 123, 123.0);
109106
}
107+
108+
// [databind#793]
109+
public void testArrayWithDefaultTyping() throws Exception
110+
{
111+
ObjectMapper mapper = new ObjectMapper()
112+
.enableDefaultTyping();
113+
114+
JsonNode array = mapper.readTree("[ 1, 2 ]");
115+
assertTrue(array.isArray());
116+
assertEquals(2, array.size());
117+
118+
JsonNode obj = mapper.readTree("{ \"a\" : 2 }");
119+
assertTrue(obj.isObject());
120+
assertEquals(1, obj.size());
121+
assertEquals(2, obj.path("a").asInt());
122+
}
110123
}

0 commit comments

Comments
 (0)