Skip to content

Commit

Permalink
Remove MethodArgumentNotValidException(Executable, BindingResult)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze authored and mdeinum committed Jun 29, 2023
1 parent 8bd2715 commit d985187
Showing 1 changed file with 3 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.web.bind;

import java.lang.reflect.Executable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -49,12 +48,8 @@
@SuppressWarnings("serial")
public class MethodArgumentNotValidException extends BindException implements ErrorResponse {

@Nullable
private final MethodParameter parameter;

@Nullable
private final Executable executable;

private final ProblemDetail body;


Expand All @@ -66,22 +61,6 @@ public class MethodArgumentNotValidException extends BindException implements Er
public MethodArgumentNotValidException(MethodParameter parameter, BindingResult bindingResult) {
super(bindingResult);
this.parameter = parameter;
this.executable = null;
this.body = ProblemDetail.forStatusAndDetail(getStatusCode(), "Invalid request content.");
}

/**
* Constructor for {@link MethodArgumentNotValidException}.
* @param executable the executable that failed validation
* @param bindingResult the results of the validation
* @since 6.0.5
* @deprecated in favor of {@link #MethodArgumentNotValidException(MethodParameter, BindingResult)}
*/
@Deprecated(since = "6.0.10", forRemoval = true)
public MethodArgumentNotValidException(Executable executable, BindingResult bindingResult) {
super(bindingResult);
this.parameter = null;
this.executable = executable;
this.body = ProblemDetail.forStatusAndDetail(getStatusCode(), "Invalid request content.");
}

Expand All @@ -105,16 +84,9 @@ public final MethodParameter getParameter() {

@Override
public String getMessage() {
StringBuilder sb = new StringBuilder("Validation failed ");
if (this.parameter != null) {
sb.append("for argument [")
.append(this.parameter.getParameterIndex()).append("] in ")
.append(this.parameter.getExecutable().toGenericString());
}
else {
sb.append("in ")
.append(this.executable.toGenericString());
}
StringBuilder sb = new StringBuilder("Validation failed for argument [")
.append(this.parameter.getParameterIndex()).append("] in ")
.append(this.parameter.getExecutable().toGenericString());
BindingResult bindingResult = getBindingResult();
if (bindingResult.getErrorCount() > 1) {
sb.append(" with ").append(bindingResult.getErrorCount()).append(" errors");
Expand Down

0 comments on commit d985187

Please sign in to comment.