Skip to content

FreeMarkerConfigurationFactory's instance variable become enlarged whenever call create method. [SPR-9389] #14025

@spring-projects-issues

Description

@spring-projects-issues

SPT Developer opened SPR-9389 and commented

"FreeMarkerConfigurationFactory.createConfiguration()" uses instance variable "templateLoaders" (List).
This method adds loaders to "templateLoaders" directly.

if (this.preTemplateLoaders != null) {
    this.templateLoaders.addAll(this.preTemplateLoaders); // Line 298
}
...

If I call this method many times, "templateLoaders" contains great number of same loader.
I think, local variable is need for loaders.

  List<TemplateLoader> templateLoaders = new ArrayList<TemplateLoader>();
    templateLoaders.addAll(this.templateLoaders);
  
    if (this.preTemplateLoaders != null) {

! templateLoaders.addAll(this.preTemplateLoaders);
}
...

Thank you for your consideration.


Affects: 3.0.3

Backported to: 3.1.4

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions