Skip to content

Commit 33cf355

Browse files
committed
Merge branch '2.18' into 2.19
2 parents 779ed28 + 2618227 commit 33cf355

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Project: jackson-databind
7171
(reported by @dbachdev)
7272
#4922: Failing `@JsonMerge` with a custom Map
7373
(reported by @nlisker)
74+
#4932: Conversion of `MissingNode` throws `JsonProcessingException`
75+
(reported by @ludgerb)
7476
7577
2.18.2 (27-Nov-2024)
7678

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4916,6 +4916,9 @@ protected Object _readValue(DeserializationConfig cfg, JsonParser p,
49164916
result = _findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
49174917
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
49184918
result = null;
4919+
} else if (t == JsonToken.NOT_AVAILABLE) {
4920+
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
4921+
result = null;
49194922
} else { // pointing to event other than null
49204923
result = ctxt.readRootValue(p, valueType, _findRootDeserializer(ctxt, valueType), null);
49214924
}
@@ -4940,6 +4943,9 @@ protected Object _readMapAndClose(JsonParser p0, JavaType valueType)
49404943
result = _findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
49414944
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
49424945
result = null;
4946+
} else if (t == JsonToken.NOT_AVAILABLE) {
4947+
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
4948+
result = null;
49434949
} else {
49444950
result = ctxt.readRootValue(p, valueType,
49454951
_findRootDeserializer(ctxt, valueType), null);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,9 @@ protected Object _bind(JsonParser p, Object valueToUpdate) throws IOException
20942094
}
20952095
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
20962096
result = valueToUpdate;
2097+
} else if (t == JsonToken.NOT_AVAILABLE) {
2098+
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
2099+
result = valueToUpdate;
20972100
} else { // pointing to event other than null
20982101
result = ctxt.readRootValue(p, _valueType, _findRootDeserializer(ctxt), _valueToUpdate);
20992102
}
@@ -2120,6 +2123,9 @@ protected Object _bindAndClose(JsonParser p0) throws IOException
21202123
}
21212124
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
21222125
result = _valueToUpdate;
2126+
} else if (t == JsonToken.NOT_AVAILABLE) {
2127+
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
2128+
result = _valueToUpdate;
21232129
} else {
21242130
result = ctxt.readRootValue(p, _valueType, _findRootDeserializer(ctxt), _valueToUpdate);
21252131
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,15 @@ public void testValueToTree() throws Exception
419419
assertEquals(wrapRootMapper.readValue(expected, Map.class), wrapRootMapper.readValue(wrapRootMapper.writeValueAsString(value), Map.class));
420420
assertEquals(wrapRootMapper.readValue(expected, Map.class), wrapRootMapper.readValue(wrapRootMapper.valueToTree(value).toString(), Map.class));
421421
}
422+
423+
// [databind#4932]: handling of `MissingNode` wrt conversions
424+
@Test
425+
public void treeToValueWithMissingNode4932() throws Exception {
426+
assertNull(MAPPER.treeToValue(MAPPER.nullNode(), Object.class));
427+
assertNull(MAPPER.treeToValue(MAPPER.missingNode(), Object.class));
428+
429+
ObjectReader r = MAPPER.readerFor(Object.class);
430+
assertNull(r.treeToValue(MAPPER.nullNode(), Object.class));
431+
assertNull(r.treeToValue(MAPPER.missingNode(), Object.class));
432+
}
422433
}

0 commit comments

Comments
 (0)