Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public boolean isExcluded(OpenApiViolation violation) {
|| falsePositiveRequestWith4xxResponse(violation)
|| customViolationExclusions.isExcluded(violation)
|| oneOfMatchesMoreThanOneSchema(violation)
|| isConcurrentModificationExceptionInLibrary(violation);
|| isConcurrentModificationExceptionInLibrary(violation)
|| isUnhandledUncheckedExecutionExceptionInLibrary(violation);
}

private static boolean oneOfMatchesMoreThanOneSchema(OpenApiViolation violation) {
Expand Down Expand Up @@ -61,4 +62,10 @@ private boolean isConcurrentModificationExceptionInLibrary(OpenApiViolation viol
return violation.getRule() != null && violation.getRule().endsWith(".body.schema.unknownError")
&& violation.getMessage().contains("java.util.ConcurrentModificationException");
}

private boolean isUnhandledUncheckedExecutionExceptionInLibrary(OpenApiViolation violation) {
return violation.getRule() != null && violation.getRule().endsWith(".body.schema.unknownError")
&& violation.getMessage().contains("UncheckedExecutionException")
&& violation.getMessage().contains("unhandled token type NOT_AVAILABLE");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ public void whenUnknownErrorWithConcurrentModificationExceptionThenViolationExcl
.build());
}

@Test
public void whenUnknownErrorWithNotAvailableTokenThenViolationExcluded() {
when(customViolationExclusions.isExcluded(any())).thenReturn(false);
String message =
"An error occurred during schema validation - com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException: unhandled token type NOT_AVAILABLE.";

checkViolationExcluded(OpenApiViolation.builder()
.direction(Direction.RESPONSE)
.rule("validation.request.body.schema.unknownError")
.responseStatus(200)
.message(message)
.build());
checkViolationExcluded(OpenApiViolation.builder()
.direction(Direction.RESPONSE)
.rule("validation.response.body.schema.unknownError")
.responseStatus(200)
.message(message)
.build());
}

private void checkViolationNotExcluded(OpenApiViolation violation) {
var isExcluded = violationExclusions.isExcluded(violation);

Expand Down
Loading