Skip to content

Commit 5ace000

Browse files
izeyewilkinsona
authored andcommitted
Remove unnecessary FieldDoesNotExistException handling
Previously, FieldDoesNotExistException was caught when extracting a field to determine whether or not it is missing (absent or an empty collection). The handling is redundant due to an earlier call to hasField so this commit removes it. Closes gh-525
1 parent 02e842d commit 5ace000

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/JsonContentHandler.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,10 @@ private boolean isMissing(FieldDescriptor candidate, Object payload) {
8484
if (!this.fieldProcessor.hasField(candidate.getPath(), payload)) {
8585
return true;
8686
}
87-
try {
88-
ExtractedField extracted = this.fieldProcessor.extract(candidate.getPath(),
89-
payload);
90-
return extracted.getValue() instanceof Collection
91-
&& ((Collection<?>) extracted.getValue()).isEmpty();
92-
}
93-
catch (FieldDoesNotExistException ex) {
94-
return true;
95-
}
87+
ExtractedField extracted = this.fieldProcessor.extract(candidate.getPath(),
88+
payload);
89+
return extracted.getValue() instanceof Collection
90+
&& ((Collection<?>) extracted.getValue()).isEmpty();
9691
}
9792

9893
@Override

0 commit comments

Comments
 (0)