Skip to content

Commit

Permalink
Update release notes wrt #3481
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 20, 2022
1 parent 96838dc commit 96d80a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Project: jackson-databind
(reported by Deniz H)
#3476: Implement `JsonNodeFeature.WRITE_NULL_PROPERTIES` to allow skipping
JSON `null` values on writing
#3481: Filter method only got called once if the field is null when using
`@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = SomeFieldFilter.class)`
(contributed by AmiDavidW@github)
#3497: Deserialization of Throwables with PropertyNamingStrategy does not work

2.13.4 (not yet released)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,10 @@ public void serializeAsField(Object bean, JsonGenerator gen,
: _accessorMethod.invoke(bean, (Object[]) null);

// Null handling is bit different, check that first
if (value == null ) {
if(_suppressableValue != null && _suppressableValue.equals(value)) {
if (value == null) {
// 20-Jun-2022, tatu: Defer checking of null, see [databind#3481]
if((_suppressableValue != null)
&& prov.includeFilterSuppressNulls(_suppressableValue)) {
return;
}
if (_nullSerializer != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ public boolean includeFilterSuppressNulls(Object filter) throws JsonMappingExcep
// But just in case, let's handle unexpected (from our perspective) problems explicitly
try {
return filter.equals(null);
} catch (Throwable t) {
} catch (Exception e) {
String msg = String.format(
"Problem determining whether filter of type '%s' should filter out `null` values: (%s) %s",
filter.getClass().getName(), t.getClass().getName(), ClassUtil.exceptionMessage(t));
reportBadDefinition(filter.getClass(), msg, t);
filter.getClass().getName(), e.getClass().getName(), ClassUtil.exceptionMessage(e));
reportBadDefinition(filter.getClass(), msg, e);
return false; // never gets here
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public void testBrokenFilter() throws Exception
String json = MAPPER.writeValueAsString(new BrokenBean(null));
fail("Should not pass, produced: "+json);
} catch (JsonMappingException e) {
verifyException(e, "while trying to invoke the method java.lang.Object.toString() of a null object loaded from local variable 'other'");
// 20-Jun-2022, tatu: Actual message seems to vary across JDKs...
verifyException(e, "Problem determining whether filter");
verifyException(e, "should filter out `null` values");
}
}
}

0 comments on commit 96d80a4

Please sign in to comment.