#1121 - Shortcut ignored property lookups to prevent NullPointerExceptions.
This commit is contained in:
@@ -204,7 +204,7 @@ public class PropertyUtils {
|
||||
.filter(descriptor -> !FIELDS_TO_IGNORE.contains(descriptor.getName()))
|
||||
.filter(descriptor -> !descriptorToBeIgnoredByJackson(type, descriptor))
|
||||
.filter(descriptor -> !toBeIgnoredByJackson(type, descriptor.getName()))
|
||||
.filter(descriptor -> !readerIsNotToBeIgnoredByJackson(descriptor));
|
||||
.filter(descriptor -> !readerIsToBeIgnoredByJackson(descriptor));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,8 +229,11 @@ public class PropertyUtils {
|
||||
* @param descriptor
|
||||
* @return
|
||||
*/
|
||||
private static boolean readerIsNotToBeIgnoredByJackson(PropertyDescriptor descriptor) {
|
||||
return toBeIgnoredByJackson(MergedAnnotations.from(descriptor.getReadMethod()));
|
||||
private static boolean readerIsToBeIgnoredByJackson(PropertyDescriptor descriptor) {
|
||||
|
||||
Method reader = descriptor.getReadMethod();
|
||||
|
||||
return reader == null ? false : toBeIgnoredByJackson(MergedAnnotations.from(reader));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,6 +156,14 @@ class PropertyUtilsTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test // #1121
|
||||
void considersPropertyWithoutReader() throws Exception {
|
||||
|
||||
InputPayloadMetadata metadata = PropertyUtils.getExposedProperties(WithoutReaderMethod.class);
|
||||
|
||||
assertThat(metadata.getPropertyMetadata("firstname")).isPresent();
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@JsonIgnoreProperties({ "ignoreThisProperty" })
|
||||
@@ -219,4 +227,13 @@ class PropertyUtilsTest {
|
||||
return employee.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
static class WithoutReaderMethod {
|
||||
|
||||
private String firstname;
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user