WW-5716 Bound the per-locale definition caches in the Tiles plugin - #1902
Open
lukaszlenart wants to merge 1 commit into
Open
WW-5716 Bound the per-locale definition caches in the Tiles plugin#1902lukaszlenart wants to merge 1 commit into
lukaszlenart wants to merge 1 commit into
Conversation
The Tiles definition caches are keyed by the resolved Locale, which by default derives from the request. Both CachingLocaleUrlDefinitionDAO's locale2definitionMap and AbstractPatternDefinitionResolver's localePatternPaths grew without limit and were never reduced for the lifetime of the web application. Bound locale2definitionMap with an insertion-order LinkedHashMap capped at maxCachedLocales (default 1000, configurable via setMaxCachedLocales). On eviction the DAO removes the same key from the pattern resolver via the new PatternDefinitionResolver#removePatternPaths, keeping both maps in lockstep (the resolver's keys are always a subset of the DAO's). localePatternPaths becomes a ConcurrentHashMap since the DAO now removes keys off the request thread. Eviction only re-incurs a load, never changes rendering. Fixes https://issues.apache.org/jira/browse/WW-5716 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015huuB72yvZygWEXKUYDAou
|
lukaszlenart
marked this pull request as ready for review
September 4, 2026 09:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The Tiles definition caches are keyed by the resolved
Locale, which by default derives from the request. Two maps grew without limit and were never reduced for the lifetime of the web application:CachingLocaleUrlDefinitionDAO#locale2definitionMap— populated on each cache miss, only cleared under the (default-off)checkRefreshpath.AbstractPatternDefinitionResolver#localePatternPaths— populated viacomputeIfAbsentper locale key, never swept.The
TilesContainerholding the DAO lives in application scope, so both maps persisted for the application lifetime, and the number of distinct keys was bounded only by the number of distinct locales encountered.Change
locale2definitionMapwith an insertion-orderLinkedHashMapcapped atmaxCachedLocales(default1000, configurable viasetMaxCachedLocales). Insertion-order (not access-order) keeps the existing unsynchronizedgetDefinitionsread unchanged.PatternDefinitionResolver#removePatternPaths, keeping both maps in lockstep — the resolver's keys are always a subset of the DAO's, since a pattern-paths entry is stored right before everylocale2definitionMapput.localePatternPathsbecomes aConcurrentHashMap, as the DAO now removes keys off the request thread.Eviction only re-incurs a load on next access; it never changes rendering. Both concrete resolvers (
BasicPatternDefinitionResolver,PrefixedPatternDefinitionResolver) inherit the new behaviour fromAbstractPatternDefinitionResolver.Tests cover the bound and that both maps evict together; the full
struts2-tiles-pluginmodule suite passes (547 tests).Fixes WW-5716
🤖 Generated with Claude Code