lukaszlenart opened a new pull request, #1902: URL: https://github.com/apache/struts/pull/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) `checkRefresh` path. - `AbstractPatternDefinitionResolver#localePatternPaths` — populated via `computeIfAbsent` per locale key, never swept. The `TilesContainer` holding 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 - Bound `locale2definitionMap` with an insertion-order `LinkedHashMap` capped at `maxCachedLocales` (default `1000`, configurable via `setMaxCachedLocales`). Insertion-order (not access-order) keeps the existing unsynchronized `getDefinitions` read unchanged. - On eviction the DAO removes the same key from the pattern resolver through the new `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 every `locale2definitionMap` put. - `localePatternPaths` becomes a `ConcurrentHashMap`, 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 from `AbstractPatternDefinitionResolver`. Tests cover the bound and that both maps evict together; the full `struts2-tiles-plugin` module suite passes (547 tests). Fixes [WW-5716](https://issues.apache.org/jira/browse/WW-5716) 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
