[
https://issues.apache.org/jira/browse/WW-5647?focusedWorklogId=1030918&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1030918
]
ASF GitHub Bot logged work on WW-5647:
--------------------------------------
Author: ASF GitHub Bot
Created on: 17/Jul/26 11:47
Start Date: 17/Jul/26 11:47
Worklog Time Spent: 10m
Work Description: arunmanni-ai commented on PR #1781:
URL: https://github.com/apache/struts/pull/1781#issuecomment-5002952094
Hi @lukaszlenart , Addressed both optional follow-ups from your review:
1. **noCache no longer pollutes the shared cache** — `getTemplates()` now
only calls `templatesCache.put()` when `!noCache`. A `noCache=true` caller
still recompiles fresh every time (unchanged), it just no longer overwrites the
cached entry other, cached callers rely on.
2. **Dedup unit test added** — `testConcurrentGetTemplatesCompilesOnce()`
races two threads through a concurrent miss on the same path and asserts
`newTemplates()` is invoked exactly once and both threads observe the same
`Templates` instance.
Also added `testNoCacheDoesNotPollutePersistentCache()` to cover (1)
directly: compiles once (cached), compiles again with `noCache=true` (different
instance, proving it recompiles), then confirms a separate `noCache=false`
caller still gets the original cached instance back.
Full suite: `mvn -pl plugins/xslt -am test -Dtest=XSLTResultTest`→ 17/17
passing (15 existing + 2 new).
Issue Time Tracking
-------------------
Worklog Id: (was: 1030918)
Time Spent: 20m (was: 10m)
> Use ConcurrentHashMap for XSLT template cache
> ---------------------------------------------
>
> Key: WW-5647
> URL: https://issues.apache.org/jira/browse/WW-5647
> Project: Struts 2
> Issue Type: Improvement
> Components: Plugin - XSLT
> Affects Versions: 7.2.1
> Reporter: Arun Manni
> Priority: Minor
> Fix For: 7.3.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> The XSLT template cache in XSLTResult uses a plain HashMap with an
> unsynchronized get() outside the synchronized block. Under concurrent
> access this can produce stale reads or exceptions from internal
> HashMap corruption.
> This patch replaces HashMap with ConcurrentHashMap for thread-safe
> reads, adds a double-check inside the synchronized block to avoid
> redundant template compilation, and removes the static initializer
> in favour of inline initialization.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)