Skip to content

Commit d0ac429

Browse files
authored
Fix for #4607: native ObjectId handling failure (#4612)
1 parent ba28fe3 commit d0ac429

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,3 +1779,8 @@ Peter Levart (plevart@github)
17791779
* Reported, contributed fix for #4575: StdDelegatingSerializer does not consider
17801780
a Converter that may return null for a non-null input
17811781
(2.17.2)
1782+
1783+
Susan Witts (susanw1@github)
1784+
* Reported #4607: `MismatchedInput`: No Object Id found for an instance of X to
1785+
assign to property '@id'
1786+
(2.17.2)

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Project: jackson-databind
1818
(reported by @dmelisso)
1919
#4595: No way to explicitly disable wrapping in custom annotation processor
2020
(reported by @SimonCockx)
21+
#4607: `MismatchedInput`: No Object Id found for an instance of X to
22+
assign to property '@id'
23+
(reported by Susan W)
2124
#4610: `DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS` does not work when
2225
used with Polymorphic type handling
2326
(fix by Joo-Hyuk K)

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,18 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
363363
final Object bean = _valueInstantiator.createUsingDefault(ctxt);
364364
// [databind#631]: Assign current value, to be accessible by custom deserializers
365365
p.assignCurrentValue(bean);
366+
367+
// First: do we have native Object Ids (like YAML)?
366368
if (p.canReadObjectId()) {
367369
Object id = p.getObjectId();
368370
if (id != null) {
369371
_handleTypedObjectId(p, ctxt, bean, id);
370372
}
371373
}
372374
// [databind#3838]: since 2.16 Uniform handling of missing objectId
373-
// only for the specific "empty JSON Object" case
374-
if (_objectIdReader != null && p.hasTokenId(JsonTokenId.ID_END_OBJECT)) {
375+
// only for the specific "empty JSON Object" case (and only for non-Native
376+
// Object Ids, see [databind#4607]
377+
else if (_objectIdReader != null && p.hasTokenId(JsonTokenId.ID_END_OBJECT)) {
375378
// [databind#4610]: check if we are to skip failure
376379
if (ctxt.isEnabled(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS)) {
377380
ctxt.reportUnresolvedObjectId(_objectIdReader, bean);

0 commit comments

Comments
 (0)