WW-5716 Bound the per-locale definition caches in the Tiles plugin (6.x) - #1903
Open
lukaszlenart wants to merge 1 commit into
Open
WW-5716 Bound the per-locale definition caches in the Tiles plugin (6.x)#1903lukaszlenart 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.



6.x backport of #1902.
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.Change
locale2definitionMapwith an insertion-orderLinkedHashMapcapped atmaxCachedLocales(default1000, configurable viasetMaxCachedLocales). Insertion-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.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. The code is Java 8 compatible (explicit type arguments on the bounded map). The full
struts2-tiles-pluginmodule suite passes (547 tests) under the Java 8 release level.Fixes WW-5716
🤖 Generated with Claude Code