Skip to content

Commit

Permalink
Update release notes wrt #3177
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 30, 2021
1 parent a05e2cb commit eade0e2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,10 @@ Morten Andersen-Gott (magott@github)
* Contributed #3174: DOM `Node` serialization omits the default namespace declaration
(2.13.0)

Klaas Sellschaft (klaasdellschaft@github)
* Contributed #3177: Support `suppressed` property when deserializing `Throwable`
(2.13.0)

Nick Benoit (nick-benoit14@github)
* Proposed #3193: Add `MapperFeature.APPLY_DEFAULT_VALUES`, initially for Scala module
(2.13.0)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Project: jackson-databind
(contributed by Tarekk Mohamed A)
#3174: DOM `Node` serialization omits the default namespace declaration
(contributed by Morten A-G)
#3177: Support `suppressed` property when deserializing `Throwable`
(contributed by Klaas D)
#3193: Add `MapperFeature.APPLY_DEFAULT_VALUES`, initially for Scala module
(suggested by Nick B)
- Fix to avoid problem with `BigDecimalNode`, scale of `Integer.MIN_VALUE` (see
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,9 @@ public enum MapperFeature implements ConfigFeature

/**
* Feature that determines whether {@link ObjectReader} applies default values
* defined in class defintions in cases where the input data omits the relevant values.
* defined in class definitions in cases where the input data omits the relevant values.
*<p>
* Not all modules will respect this feature. Initially, only jackson-module-scala
* Not all modules will respect this feature. Initially, only {@code jackson-module-scala}
* will respect this feature but other modules will add support over time.
*<p>
* Feature is enabled by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class ThrowableDeserializer
protected final static String PROP_NAME_SUPPRESSED = "suppressed";

/*
/************************************************************
/* Construction
/************************************************************
/**********************************************************************
/* Life-cycle
/**********************************************************************
*/

public ThrowableDeserializer(BeanDeserializer baseDeserializer) {
Expand All @@ -45,17 +45,16 @@ public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper
if (getClass() != ThrowableDeserializer.class) {
return this;
}
/* main thing really is to just enforce ignoring of unknown
* properties; since there may be multiple unwrapped values
* and properties for all may be interleaved...
*/
// main thing really is to just enforce ignoring of unknown
// properties; since there may be multiple unwrapped values
// and properties for all may be interleaved...
return new ThrowableDeserializer(this, unwrapper);
}

/*
/************************************************************
/**********************************************************************
/* Overridden methods
/************************************************************
/**********************************************************************
*/

@Override
Expand All @@ -81,7 +80,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
"Throwable needs a default constructor, a single-String-arg constructor; or explicit @JsonCreator");
}

Object throwable = null;
Throwable throwable = null;
Object[] pending = null;
Throwable[] suppressed = null;
int pendingIx = 0;
Expand All @@ -107,17 +106,12 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
}

// Maybe it's "message"?
final boolean isMessage = PROP_NAME_MESSAGE.equals(propName);
if (isMessage) {
if (PROP_NAME_MESSAGE.equals(propName)) {
if (hasStringCreator) {
throwable = _valueInstantiator.createFromString(ctxt, p.getValueAsString());
throwable = (Throwable) _valueInstantiator.createFromString(ctxt, p.getValueAsString());
continue;
}
}

// Maybe it's "suppressed"?
final boolean isSuppressed = PROP_NAME_SUPPRESSED.equals(propName);
if (isSuppressed) {
} else if (PROP_NAME_SUPPRESSED.equals(propName)) { // or "suppressed"?
suppressed = ctxt.readValue(p, Throwable[].class);
continue;
}
Expand Down Expand Up @@ -146,9 +140,9 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
*/
//throw new XxxException("No 'message' property found: could not deserialize "+_beanType);
if (hasStringCreator) {
throwable = _valueInstantiator.createFromString(ctxt, null);
throwable = (Throwable) _valueInstantiator.createFromString(ctxt, null);
} else {
throwable = _valueInstantiator.createUsingDefault(ctxt);
throwable = (Throwable) _valueInstantiator.createUsingDefault(ctxt);
}
}

Expand All @@ -161,10 +155,9 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
}

// any suppressed exceptions?
if (suppressed != null && throwable instanceof Throwable) {
Throwable t = (Throwable) throwable;
if (suppressed != null) {
for (Throwable s : suppressed) {
t.addSuppressed(s);
throwable.addSuppressed(s);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String toString() {

public void testDupProps() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = newJsonMapper();
EnvironmentEvent event = new BackendEvent("foo", "hello", "bar", null);
String ser = mapper
.writerWithDefaultPrettyPrinter()
Expand Down

0 comments on commit eade0e2

Please sign in to comment.