spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.64k stars 38.14k forks source link

Backward compatibility of BeanUtils.copyProperties broken for copying wrapped types to primitive types (and vice versa) on 3.2.6 and 4.0.0 [SPR-11231] #15856

Closed spring-projects-issues closed 10 years ago

spring-projects-issues commented 10 years ago

Chad Wilson opened SPR-11231 and commented

The change made for #15834 in https://github.com/spring-projects/spring-framework/commit/bc5affa79a67b28c858730dd69156ebf6161164a appears to have broken backward compatibility for primitive types where boxing/autoboxing was required between read and write methods.

Boolean.class is not "assignable" from boolean.class (and similar for other types) however this previously worked fine using BeanUtils.copyProperties, relying on auto boxing/unboxing.

Was this change intentional?

Could you consider using org.springframework.util.ClassUtils@isAssignable(lhsType, rhsType) to handle this without breaking backwards compatibility?


Affects: 3.2.6, 4.0 GA

Referenced from: commits https://github.com/spring-projects/spring-framework/commit/8a3b4c69c89d0bf56ef210f5166c79ee77be3935, https://github.com/spring-projects/spring-framework/commit/0a4d28d5d54aa179f5a9cde21db3ad8b9a671199

Backported to: 3.2.7

spring-projects-issues commented 10 years ago

Francesco Chicchiricco commented

Found same issue when trying to update Apache Syncope from Spring 3.2.5 to Spring 3.2.6 (took quite a while to understand, then found this issue via #15834). I have opened SYNCOPE-462, which is blocked by this issue.

spring-projects-issues commented 10 years ago

Juergen Hoeller commented

Good catch! Fixed for 4.0.1 and 3.2.7 now, both to be released in January.

Juergen

spring-projects-issues commented 10 years ago

Chad Wilson commented

Thanks Juergen, appreciated.