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)
   


-- 
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]

Reply via email to