[
https://issues.apache.org/jira/browse/WW-5668?focusedWorklogId=1032978&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1032978
]
ASF GitHub Bot logged work on WW-5668:
--------------------------------------
Author: ASF GitHub Bot
Created on: 30/Jul/26 09:36
Start Date: 30/Jul/26 09:36
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #1821:
URL: https://github.com/apache/struts/pull/1821
Fixes [WW-5668](https://issues.apache.org/jira/browse/WW-5668)
Follow-up to WW-5540. Two related, independent changes to the localized-text
subsystem.
## 1. Bounded localized-text caches
`AbstractLocalizedTextProvider` kept its five internal caches (`bundlesMap`,
`messageFormats`, `missingBundles`, and the `classHierarchyCache` /
`packageHierarchyCache` added in WW-5540) as plain `ConcurrentHashMap`s with no
configurable upper bound or eviction. The rest of the framework already
standardises on bounded caches via `OgnlCacheFactory`
(`struts.ognl.expressionCacheMaxSize`, `struts.proxy.cacheMaxSize`, both
`wtlfu`); these were the outlier.
- Reuse the existing `OgnlCache` abstraction (`DefaultOgnlCacheFactory`) for
all five caches, with configurable size and eviction.
- New constants `struts.i18n.cacheType` (default `wtlfu`) and
`struts.i18n.cacheMaxSize` (default `10000`), documented in
`default.properties`.
- Added `remove(key)` to `OgnlCache` (needed by `clearBundle`).
- Caches are `transient` and rebuilt in `readObject` so the provider stays
serializable; a dedicated lock replaces synchronizing on the now-reassignable
`bundlesMap`.
All five caches are pure/reconstructible, so eviction can only cause a
recompute, never a wrong or stale localized result.
## 2. Consistent request-locale resolution (opt-in)
`I18nInterceptor` validates a resolved locale against the available-locale
set (`LocaleProvider.isValidLocale`), but `Dispatcher.getLocale(...)` (used
when `struts.locale` is unset) returns `request.getLocale()` directly without
that check.
- New `struts.locale.validateRequestLocale` (default `false` — current
behaviour preserved byte-for-byte). When enabled, `Dispatcher` resolves
request-derived locales against the JVM available-locale set, falling back to
the configured `struts.locale` (else the JVM default), consistent with
`I18nInterceptor`.
## Testing
- New tests: cache bound invariant, correctness under eviction, reload
clears, serialize→deserialize→`findText`, cache-type selection, and the three
`Dispatcher` flag states (off / on-available / on-fallback).
- Full `core` suite green.
## Backward compatibility
- Part 1 changes internal cache implementations only; eviction is
correctness-safe; defaults match existing cache conventions.
- Part 2 is fully opt-in and defaults off.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1032978)
Remaining Estimate: 0h
Time Spent: 10m
> Make the localized-text provider caches size-bounded and align request-locale
> resolution across entry points
> ------------------------------------------------------------------------------------------------------------
>
> Key: WW-5668
> URL: https://issues.apache.org/jira/browse/WW-5668
> Project: Struts 2
> Issue Type: Improvement
> Reporter: Lukasz Lenart
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 7.3.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Two related follow-ups to the localized-text provider work in WW-5540.
> h2. 1. Bounded caches, consistent with the rest of the framework
> {{AbstractLocalizedTextProvider}} keeps several internal caches --
> {{bundlesMap}}, {{messageFormats}}, {{missingBundles}}, and the
> {{classHierarchyCache}} / {{packageHierarchyCache}} added in WW-5540. These
> are plain {{ConcurrentHashMap}}s with no configurable upper bound or eviction
> policy.
> Elsewhere the framework already standardises on bounded, configurable caches:
> the OGNL expression cache ({{struts.ognl.expressionCacheType=wtlfu}},
> {{struts.ognl.expressionCacheMaxSize=10000}}), the BeanInfo cache, and the
> proxy detection cache ({{struts.proxy.cacheMaxSize=10000}}) all support a
> cache type and a maximum size via {{OgnlCacheFactory}} /
> {{DefaultOgnlCacheFactory}}. The localized-text caches are the outlier.
> Bring them in line: give the localized-text caches a configurable maximum
> size and eviction (reusing the existing cache abstraction), with new
> constants following the established naming, e.g. {{struts.i18n.cacheType}}
> and {{struts.i18n.cacheMaxSize}}, defaulting to the same {{wtlfu}} /
> {{10000}} as the OGNL and proxy caches. Normal localized-text behaviour must
> be unchanged for typical applications.
> h2. 2. Consistent request-locale resolution
> Struts resolves a request locale from more than one place, and the two paths
> behave differently:
> * {{I18nInterceptor}} (the {{request_locale}} parameter / cookie / session
> path) resolves the value and then checks it against the available-locale set
> via {{LocaleProvider.isValidLocale(...)}}, falling back to the configured
> default when the resolved locale is not an available one.
> * {{Dispatcher.getLocale(...)}} -- used when {{struts.locale}} is unset --
> returns {{request.getLocale()}} directly, without that availability check.
> Align the two so a request-derived locale is resolved consistently regardless
> of entry point (a shared resolve/validate boundary, applying the same
> available-locale check the interceptor already uses).
> h2. Scope / acceptance
> * Localized-text caches honour a configurable maximum size with eviction;
> defaults match the existing OGNL/proxy cache conventions.
> * Request-locale resolution is consistent across {{Dispatcher}} and
> {{I18nInterceptor}}.
> * Documented in {{default.properties}} alongside the other cache settings.
> * Tests: cache size stays within the configured bound as locale/key diversity
> grows; correct localized text is still returned for normal and repeated
> locales; locale resolution behaviour is covered for both entry points.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)