lukaszlenart opened a new pull request, #1915: URL: https://github.com/apache/struts/pull/1915
Fixes [WW-5724](https://issues.apache.org/jira/browse/WW-5724) Backport of #1914 to the 6.x line. `AbstractLocalizedTextProvider` caches `MessageFormat` instances by pattern and locale and returned the cached instance itself from `buildMessageFormat`. `MessageFormat` is not thread-safe, so concurrent callers rendering the same message formatted through one shared instance; with a date or time sub-format that produced output for the wrong argument or an exception. `buildMessageFormat` now returns a clone of the cached instance, so the cached entry is only ever a template and is never formatted directly. `MessageFormat.clone()` deep-copies the sub-formats on Java 8 as well (`Calendar`, `DigitList`, `DateFormatSymbols`). The pattern-parsing cache is kept. Two tests added to `StrutsLocalizedTextProviderTest`, matching the main change: one asserts two lookups of the same pattern no longer return the same instance while the cache still holds one entry; the other renders a `{0,date,short}` message from four threads with distinct dates and asserts every output matches its own argument. Both failed before the change. No configuration or API change. 🤖 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]
