You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify behavior for generics support in BeanUtils.copyProperties #27259
This is a potential regression introduced in conjunction with #24187.
@afattahi54, can you please also provide the setter and getter methods of those two classes so that we can inspect the actual method signatures?
Also, if Signer is not a subtype of TransferSigners, why would you expect BeanUtils to copy from List<Signer> to List<TransferSigners>?
Doing so would actually store items in the List<TransferSigners> that are not an instance of TransferSigners, and that would be a broken state.
@sbrannen spring-beans version is 5.3.9, when Signer is a subtype of TransferSigners,use the BeanUtils.copyProperties(transferVO , transferRequest). the transferVO.signers is null. but when spring-beans version is 5.1.16.RELEASE is normal. I hope the new version is compatible with the previous version.
changed the title [-]BeanUtils.copyProperties breaks from 5.2.9.RELEASE to 5.3.7[/-][+]Clarify behavior for generics support in BeanUtils.copyProperties[/+]on Mar 12, 2022
The Signer and TransferSigners do not have same types. You are right, but as it was working before upgrade to 5.3.7 I expected it to keep working
@afattahi54, since BeanUtils.copyProperties() honors generics since Spring Framework 5.3, you will need to ensure that the source and target property types are compatible in terms of Java semantics.
spring-beans version is 5.3.9, when Signer is a subtype of TransferSigners,use the BeanUtils.copyProperties(transferVO , transferRequest). the transferVO.signers is null. but when spring-beans version is 5.1.16.RELEASE is normal. I hope the new version is compatible with the previous version.
@bigdata-page, that can be addressed by using an upper-bounded wildcard for the target property type.
In commit 887389d, I added a table to the Javadoc for BeanUtils.copyProperties() which will hopefully help you and other users better understand the current semantics for property type matching.
Activity
sbrannen commentedon Aug 12, 2021
This is a potential regression introduced in conjunction with #24187.
@afattahi54, can you please also provide the setter and getter methods of those two classes so that we can inspect the actual method signatures?
Also, if
Signeris not a subtype ofTransferSigners, why would you expectBeanUtilsto copy fromList<Signer>toList<TransferSigners>?Doing so would actually store items in the
List<TransferSigners>that are not an instance ofTransferSigners, and that would be a broken state.afattahi54 commentedon Aug 14, 2021
The
SignerandTransferSignersdo not have same types. You are right, but as it was working before upgrade to5.3.7I expected it to keep workingThe setters and getters are as below:
Thanks
bigdata-page commentedon Nov 24, 2021
@sbrannen spring-beans version is 5.3.9, when Signer is a subtype of TransferSigners,use the BeanUtils.copyProperties(transferVO , transferRequest). the transferVO.signers is null. but when spring-beans version is 5.1.16.RELEASE is normal. I hope the new version is compatible with the previous version.
sbrannen commentedon Nov 29, 2021
Assigned to the Triage Queue so that the team can determine if this is a regression that needs to be fixed.
[-]BeanUtils.copyProperties breaks from 5.2.9.RELEASE to 5.3.7[/-][+]Clarify behavior for generics support in BeanUtils.copyProperties[/+]Clarify behavior for generics support in BeanUtils.copyProperties()
sbrannen commentedon Mar 12, 2022
@afattahi54, since
BeanUtils.copyProperties()honors generics since Spring Framework 5.3, you will need to ensure that the source and target property types are compatible in terms of Java semantics.@bigdata-page, that can be addressed by using an upper-bounded wildcard for the target property type.
In commit 887389d, I added a table to the Javadoc for
BeanUtils.copyProperties()which will hopefully help you and other users better understand the current semantics for property type matching.