-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BeanUtils does not copy properties with generics from a Proxy since 5.3.0 #26531
Comments
I'm afraid I can't build that application:
Can you isolate the problem into a smaller sample that we can easily run? I can't see any obvious change in |
|
I could set up a smaller spring boot project in order to demonstrate this. However, I am afraid I won't be able to do this before friday. Would that be ok for you? |
@rreitmann That would be great, thanks. The |
I had some time for this today, so here is the test in a smaller project which fails in 2.4.2 but passes in 2.3.8: |
I have confirmed that this is a regression beginning with Spring Framework 5.3.0 due to #24281 as suggested by @mbhave. My initial analysis is that the type information is lost when using |
This has been fixed in Feel free to give it a try and let us know if you run into any issues. |
Thanks for the quick fix, I will wait until it is part of a spring boot release. |
spring-projectsgh-24281 introduced support to honor generic type information in BeanUtils.copyProperties(), but that introduced a regression. Specifically, if the supplied source or target object lacked generic type information for the return type of the read-method or the parameter type of the write-method for a given property, respectively, the two properties would be considered a mismatch and ignored. This can occur if the source or target object is a java.lang.reflect.Proxy since the dynamically generated class for the proxy loses the generic type information from interfaces that the proxy implements. This commit fixes this regression by ignoring generic type information if either the source or target property is lacking generic type information. Closes spring-projectsgh-26531
After upgrading from spring boot 2.3.8 to 2.4.2 our following test case fails:
CopyPropertiesTest
Basically it loads a spring data projection from MongoDB and tries to copy all of its properties with Spring's
BeanUtils.copyProperties
into another bean. For some reason "collection"-properties are not copied anymore after the upgrade.The text was updated successfully, but these errors were encountered: