Skip to content

GuavaCacheManager ignores cache specification due to eager initialization of internal cache map with static cache names [SPR-12120] #16736

Closed
@spring-projects-issues

Description

@spring-projects-issues

Frank Scheffler opened SPR-12120 and commented

We are using GuavaCacheManagers with explicit cache names configured, since we combine them using the CompositeCacheManager and require different cache specifications for each cache. When injection both a cache builder specification and cache names, the order of calling the appropriate setters is important, since setCacheNames() eagerly initializes the internal cache map, while setCacheSpecification() then tries to modify the CacheBuilder. Thus, the specification is effectively ignored without any errors.

I strongly suggest storing the configured cache names as list of strings and initializing them in an afterPropertiesSet() method.

So far, our work-around is to switch the order of the property XML tags in our XML configuration file, but this seems odd, since the order usually shouldn't matter.


Affects: 4.0.6

Issue Links:

Referenced from: commits d47c543, e1a01d4

Backported to: 4.0.7

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)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