From 17858e970a3c4b2d1336ba34a139fa002d88c48f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 15 Jan 2025 20:51:54 -0800 Subject: [PATCH] Minor fix to "current value" setting wrt view processing --- .../jackson/databind/deser/BeanDeserializer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java index a3735602b1..aac1955076 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java @@ -361,8 +361,6 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t return bean; } final Object bean = _valueInstantiator.createUsingDefault(ctxt); - // [databind#631]: Assign current value, to be accessible by custom deserializers - p.assignCurrentValue(bean); // First: do we have native Object Ids (like YAML)? if (p.canReadObjectId()) { @@ -390,6 +388,9 @@ else if (_objectIdReader != null && p.hasTokenId(JsonTokenId.ID_END_OBJECT)) { } } if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) { + // [databind#631]: Assign current value, to be accessible by custom serializers + // [databind#4184]: but only if we have at least one property + p.assignCurrentValue(bean); String propName = p.currentName(); do { p.nextToken(); @@ -680,6 +681,9 @@ protected final Object deserializeWithView(JsonParser p, DeserializationContext throws IOException { if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) { + // [databind#631]: Assign current value, to be accessible by custom serializers + // [databind#4184]: but only if we have at least one property + p.assignCurrentValue(bean); String propName = p.currentName(); do { p.nextToken();