-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
Adam Chesney opened SPR-17055 and commented
Attached is a zipped up Spring Boot 2.1 SNAPSHOT web project showing the problem.
A method like this:
@JsonIgnore
@AssertTrue
private boolean isNameNotFoo(){
return name != null && !name.equalsIgnoreCase("foo");
}
In a nested element that appears in a List of items in a request object causes a 500 when it fails validation.
So this json is fine and returns 200:
{"things":[{"name":"bar"}]}
But this json:
{"things":[{"name":"foo"}]}
blows up with 500:
> Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: JSR-303 validated property 'things[0].nameNotFoo' does not have a corresponding accessor for Spring data binding - check your DataBinder's configuration (bean property versus direct field access)] with root cause``org.springframework.beans.NotReadablePropertyException: Invalid property 'things[0].nameNotFoo' of bean class [com.example.validationfail.api.OuterThing]: Bean property 'things[0].nameNotFoo' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
> at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:622) ~[spring-beans-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
> at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:612) ~[spring-beans-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
> at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:104) ~[spring-context-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
> at org.springframework.validation.AbstractBindingResult.getRawFieldValue(AbstractBindingResult.java:284) ~[spring-context-5.1.0.BUILD-SNAPSHOT.jar:5.1.0.BUILD-SNAPSHOT]
Affects: 5.0.8
Attachments:
- validation-fail.zip (101.23 kB)
bytrogenix, Attacktive and ranjeetsingh-logistimo
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid