From 021000fd65a2df5cd26562bbc5fd3aede7b1bb4b Mon Sep 17 00:00:00 2001 From: Klaas Dellschaft Date: Mon, 28 Jun 2021 12:33:27 +0200 Subject: [PATCH] Implement #3177 Addressing review comment. Small refactoring in order to reduce code duplication. --- .../deser/std/ThrowableDeserializer.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java index ae6b3ad0cf..faae38c470 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer.java @@ -111,14 +111,6 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t if (isMessage) { if (hasStringCreator) { throwable = _valueInstantiator.createFromString(ctxt, p.getValueAsString()); - // any pending values? - if (pending != null) { - for (int i = 0, len = pendingIx; i < len; i += 2) { - prop = (SettableBeanProperty)pending[i]; - prop.set(throwable, pending[i+1]); - } - pending = null; - } continue; } } @@ -126,7 +118,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t // Maybe it's "suppressed"? final boolean isSuppressed = PROP_NAME_SUPPRESSED.equals(propName); if (isSuppressed) { - suppressed = p.readValueAs(Throwable[].class); + suppressed = ctxt.readValue(p, Throwable[].class); continue; } @@ -158,15 +150,17 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t } else { throwable = _valueInstantiator.createUsingDefault(ctxt); } - // any pending values? - if (pending != null) { - for (int i = 0, len = pendingIx; i < len; i += 2) { - SettableBeanProperty prop = (SettableBeanProperty)pending[i]; - prop.set(throwable, pending[i+1]); - } + } + + // any pending values? + if (pending != null) { + for (int i = 0, len = pendingIx; i < len; i += 2) { + SettableBeanProperty prop = (SettableBeanProperty)pending[i]; + prop.set(throwable, pending[i+1]); } } + // any suppressed exceptions? if (suppressed != null && throwable instanceof Throwable) { Throwable t = (Throwable) throwable; for (Throwable s : suppressed) {