Skip to content

Clarify AbstractResourceBasedMessageSource.setCacheMillis vs java.util.ResourceBundle #24563

@destan

Description

@destan

Affects: 4.x, 5.x


In Javadoc of org.springframework.context.support.AbstractResourceBasedMessageSource#setCacheMillis
it says:

Default is "-1", indicating to cache forever (just like java.util.ResourceBundle).

However -1 in java.util.ResourceBundle is TTL_DONT_CACHE and its effect is not cache forever.

It should be TTL_NO_EXPIRATION_CONTROL = -2 to have the cache forever effect.

Hence I think implementation of org.springframework.context.support.ResourceBundleMessageSource#getResourceBundle is inconsistent with java.util.ResourceBundle.

it caches forever for any value less than 0. In order to be consistent with java.util.ResourceBundle it should be as follows

if (getCacheMillis() >= -1) {
	return doGetBundle(basename, locale);
}
else {
	// Cache forever...
}

and call doGetBundle for TTL_DONT_CACHE = -1 as well.

@jhoeller what do you think about it?

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: documentationA documentation task

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions