Skip to content

CollectionToCollectionConverter.convert() improvement for untyped collections [SPR-11479] #16104

Closed
@spring-projects-issues

Description

@spring-projects-issues

Gary Russell opened SPR-11479 and commented

Consider

  • source : ArrayList
  • sourceType : java.util.ArrayList<?>
  • targetType : java.util.Collection<?>

Line #63...

https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/convert/support/CollectionToCollectionConverter.java#L63

...determines that copyRequired == false .

However, line 70 then proceeds to copy the elements from the source to the target, which is eventually discarded, when line #84 simply returns the source.

It looks to me like it should have

if (copyRequired) {} 
``` around the for loop. The else clause needs to run, in case `copyRequired` gets changed to true.

Affects: 3.2.8, 4.0.2

Issue Links:

  • INT-3306 Aggregator memory usage raises serious performance issue

Referenced from: commits bea94d5, d317b63

Backported to: 3.2.9

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions