@@ -22,9 +22,9 @@ public class ThrowableDeserializer
22
22
protected final static String PROP_NAME_SUPPRESSED = "suppressed" ;
23
23
24
24
/*
25
- /************************************************************
26
- /* Construction
27
- /************************************************************
25
+ /**********************************************************************
26
+ /* Life-cycle
27
+ /**********************************************************************
28
28
*/
29
29
30
30
public ThrowableDeserializer (BeanDeserializer baseDeserializer ) {
@@ -45,17 +45,16 @@ public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper
45
45
if (getClass () != ThrowableDeserializer .class ) {
46
46
return this ;
47
47
}
48
- /* main thing really is to just enforce ignoring of unknown
49
- * properties; since there may be multiple unwrapped values
50
- * and properties for all may be interleaved...
51
- */
48
+ // main thing really is to just enforce ignoring of unknown
49
+ // properties; since there may be multiple unwrapped values
50
+ // and properties for all may be interleaved...
52
51
return new ThrowableDeserializer (this , unwrapper );
53
52
}
54
53
55
54
/*
56
- /************************************************************
55
+ /**********************************************************************
57
56
/* Overridden methods
58
- /************************************************************
57
+ /**********************************************************************
59
58
*/
60
59
61
60
@ Override
@@ -81,7 +80,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
81
80
"Throwable needs a default constructor, a single-String-arg constructor; or explicit @JsonCreator" );
82
81
}
83
82
84
- Object throwable = null ;
83
+ Throwable throwable = null ;
85
84
Object [] pending = null ;
86
85
Throwable [] suppressed = null ;
87
86
int pendingIx = 0 ;
@@ -107,17 +106,12 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
107
106
}
108
107
109
108
// Maybe it's "message"?
110
- final boolean isMessage = PROP_NAME_MESSAGE .equals (propName );
111
- if (isMessage ) {
109
+ if (PROP_NAME_MESSAGE .equals (propName )) {
112
110
if (hasStringCreator ) {
113
- throwable = _valueInstantiator .createFromString (ctxt , p .getValueAsString ());
111
+ throwable = ( Throwable ) _valueInstantiator .createFromString (ctxt , p .getValueAsString ());
114
112
continue ;
115
113
}
116
- }
117
-
118
- // Maybe it's "suppressed"?
119
- final boolean isSuppressed = PROP_NAME_SUPPRESSED .equals (propName );
120
- if (isSuppressed ) {
114
+ } else if (PROP_NAME_SUPPRESSED .equals (propName )) { // or "suppressed"?
121
115
suppressed = ctxt .readValue (p , Throwable [].class );
122
116
continue ;
123
117
}
@@ -146,9 +140,9 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
146
140
*/
147
141
//throw new XxxException("No 'message' property found: could not deserialize "+_beanType);
148
142
if (hasStringCreator ) {
149
- throwable = _valueInstantiator .createFromString (ctxt , null );
143
+ throwable = ( Throwable ) _valueInstantiator .createFromString (ctxt , null );
150
144
} else {
151
- throwable = _valueInstantiator .createUsingDefault (ctxt );
145
+ throwable = ( Throwable ) _valueInstantiator .createUsingDefault (ctxt );
152
146
}
153
147
}
154
148
@@ -161,10 +155,9 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
161
155
}
162
156
163
157
// any suppressed exceptions?
164
- if (suppressed != null && throwable instanceof Throwable ) {
165
- Throwable t = (Throwable ) throwable ;
158
+ if (suppressed != null ) {
166
159
for (Throwable s : suppressed ) {
167
- t .addSuppressed (s );
160
+ throwable .addSuppressed (s );
168
161
}
169
162
}
170
163
0 commit comments