Skip to content

Commit

Permalink
Always use MethodArgumentNotValidException(MethodParameter, BindingRe…
Browse files Browse the repository at this point in the history
…sult) constructor

gh-23846 introduced a new
MethodArgumentNotValidException(Executable, BindingResult)
constructor that can be advantageously replaced by using
MethodArgumentNotValidException(MethodParameter, BindingResult)
in ModelAttributeMethodProcessor.

This commit updates ModelAttributeMethodProcessor accordingly,
and deprecates MethodArgumentNotValidException(Executable,
BindingResult) in favor of
MethodArgumentNotValidException(MethodParameter, BindingResult).

Closes gh-30558
  • Loading branch information
sdeleuze committed May 30, 2023
1 parent 7a05f81 commit 2cbc7ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Expand Up @@ -75,7 +75,9 @@ public MethodArgumentNotValidException(MethodParameter parameter, BindingResult
* @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;
Expand Down
Expand Up @@ -341,7 +341,7 @@ public Object getTarget() {
BindingResult result = binder.getBindingResult();
ObjectError error = new ObjectError(ctor.getName(), cause.getMessage());
result.addError(error);
throw new MethodArgumentNotValidException(ctor, result);
throw new MethodArgumentNotValidException(parameter, result);
}
else {
throw ex;
Expand Down

0 comments on commit 2cbc7ee

Please sign in to comment.