Skip to content

Commit

Permalink
Fix target in BindValidationFailureAnalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye authored and mhalbritter committed Apr 16, 2024
1 parent 3b98056 commit 201885a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ protected FailureAnalysis analyze(Throwable rootFailure, Throwable cause) {
private ExceptionDetails getBindValidationExceptionDetails(Throwable rootFailure) {
BindValidationException validationException = findCause(rootFailure, BindValidationException.class);
if (validationException != null) {
BindException target = findCause(rootFailure, BindException.class);
BindException bindException = findCause(rootFailure, BindException.class);
List<ObjectError> errors = validationException.getValidationErrors().getAllErrors();
return new ExceptionDetails(errors, target, validationException);
return new ExceptionDetails(errors, bindException.getTarget().getType(), validationException);
}
org.springframework.validation.BindException bindException = findCause(rootFailure,
org.springframework.validation.BindException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ void cleanup() {
@Test
void bindExceptionWithFieldErrorsDueToValidationFailure() {
FailureAnalysis analysis = performAnalysis(FieldValidationFailureConfiguration.class);
assertThat(analysis.getDescription()).contains(failure("test.foo.foo", "null", "must not be null"));
assertThat(analysis.getDescription()).contains(failure("test.foo.value", "0", "at least five"));
assertThat(analysis.getDescription()).contains(failure("test.foo.nested.bar", "null", "must not be null"));
assertThat(analysis.getDescription()).contains(failure("test.foo.foo", "null", "must not be null"))
.contains(failure("test.foo.value", "0", "at least five"))
.contains(failure("test.foo.nested.bar", "null", "must not be null"))
.contains(
"Binding to target org.springframework.boot.diagnostics.analyzer.BindValidationFailureAnalyzerTests$FieldValidationFailureProperties failed:");
}

@Test
Expand Down

0 comments on commit 201885a

Please sign in to comment.