-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Elad Tabak opened SPR-15689 and commented
org.springframework.beans.BeanUtils.copyProperties() copy fields of generic collections even if the generic types do not match.
This result in a strange behavior when a bean that have a collection of <A> will get values of <B>.
See example class:
There are two bean classes - X and Y. Both have a field "list" of different types - X have a list of <A> and Y have a list of <B>.
The result after a BeanUtils.copyProperties(x,y) is that y have a list of <A> even though it's a type mismatch.
Generic data is problematic to establish in case the collection is empty, but if it's not, it's possible to not set the field. Of course this is a best-effort for a specific use case of 2 beans of different types.
Affects: 4.3.9
Attachments:
- TestBeanUtils.java (1.10 kB)