16
16
17
17
package org .springframework .web .bind ;
18
18
19
- import java .lang .reflect .Executable ;
20
19
import java .util .ArrayList ;
21
20
import java .util .LinkedHashMap ;
22
21
import java .util .List ;
49
48
@ SuppressWarnings ("serial" )
50
49
public class MethodArgumentNotValidException extends BindException implements ErrorResponse {
51
50
52
- @ Nullable
53
51
private final MethodParameter parameter ;
54
52
55
- @ Nullable
56
- private final Executable executable ;
57
-
58
53
private final ProblemDetail body ;
59
54
60
55
@@ -66,22 +61,6 @@ public class MethodArgumentNotValidException extends BindException implements Er
66
61
public MethodArgumentNotValidException (MethodParameter parameter , BindingResult bindingResult ) {
67
62
super (bindingResult );
68
63
this .parameter = parameter ;
69
- this .executable = null ;
70
- this .body = ProblemDetail .forStatusAndDetail (getStatusCode (), "Invalid request content." );
71
- }
72
-
73
- /**
74
- * Constructor for {@link MethodArgumentNotValidException}.
75
- * @param executable the executable that failed validation
76
- * @param bindingResult the results of the validation
77
- * @since 6.0.5
78
- * @deprecated in favor of {@link #MethodArgumentNotValidException(MethodParameter, BindingResult)}
79
- */
80
- @ Deprecated (since = "6.0.10" , forRemoval = true )
81
- public MethodArgumentNotValidException (Executable executable , BindingResult bindingResult ) {
82
- super (bindingResult );
83
- this .parameter = null ;
84
- this .executable = executable ;
85
64
this .body = ProblemDetail .forStatusAndDetail (getStatusCode (), "Invalid request content." );
86
65
}
87
66
@@ -105,16 +84,9 @@ public final MethodParameter getParameter() {
105
84
106
85
@ Override
107
86
public String getMessage () {
108
- StringBuilder sb = new StringBuilder ("Validation failed " );
109
- if (this .parameter != null ) {
110
- sb .append ("for argument [" )
111
- .append (this .parameter .getParameterIndex ()).append ("] in " )
112
- .append (this .parameter .getExecutable ().toGenericString ());
113
- }
114
- else {
115
- sb .append ("in " )
116
- .append (this .executable .toGenericString ());
117
- }
87
+ StringBuilder sb = new StringBuilder ("Validation failed for argument [" )
88
+ .append (this .parameter .getParameterIndex ()).append ("] in " )
89
+ .append (this .parameter .getExecutable ().toGenericString ());
118
90
BindingResult bindingResult = getBindingResult ();
119
91
if (bindingResult .getErrorCount () > 1 ) {
120
92
sb .append (" with " ).append (bindingResult .getErrorCount ()).append (" errors" );
0 commit comments