Affects: Spring 5.0.9 / Boot 2.0.5

We have a Spring Web Mvc REST service implemented using DTO models which are validated using @Valid on controller method signatures. Those DTO models had simple public fields like String, Instant etc. and validation worked fine. Then we introduced nested complex objects and referenced them via @Valid from the root object. After that we encountered, that Spring was complaining about not being able to find bean properties for the complex objects. After we setup the controllers using direct field access via @InitBinder that started to work again.

The first question that came up was: why is there inconsistent behavior? The binding of public simple fields without getter/setters is apparently working with the default (=bean property binding) config. But as soon as someone is adding nested complex objects, it starts to fail. This seems at least odd to us. Is this expected behavior?

What we also encountered is, if those complex nested objects, are "after" a collection, like a Set or List, in the object graph, validation still seems to work properly (using public fields, without having to enable direct field access). Is this a known issue or a bug?

Comment From: snicoll

We can't say for sure as you haven't shared an example of what you've done. The nested object should be flagged @Valid for it to be considered. If you're still affected, please share a small sample we can run ourselves that showcases what you feel is not to be expected.

You can attach a zip to this issue or push the code to a separate GitHub repository.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.