[ 
https://issues.apache.org/jira/browse/WW-5724?focusedWorklogId=1040948&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1040948
 ]

ASF GitHub Bot logged work on WW-5724:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Sep/26 13:55
            Start Date: 11/Sep/26 13:55
    Worklog Time Spent: 10m 
      Work Description: sonarqubecloud[bot] commented on PR #1915:
URL: https://github.com/apache/struts/pull/1915#issuecomment-5635466824

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1915) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 New 
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1915&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=1915&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=1915&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [100.0% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1915&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Duplication on New 
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1915&metric=new_duplicated_lines_density&view=list)
  
     
   <!

Issue Time Tracking
-------------------

    Worklog Id:     (was: 1040948)
    Time Spent: 40m  (was: 0.5h)

> Cached MessageFormat instances in AbstractLocalizedTextProvider are shared 
> between concurrent callers
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WW-5724
>                 URL: https://issues.apache.org/jira/browse/WW-5724
>             Project: Struts 2
>          Issue Type: Bug
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 6.12.0, 7.4.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> h2. Summary
> {{AbstractLocalizedTextProvider}} caches {{java.text.MessageFormat}} 
> instances keyed by pattern and locale and returns the cached instance from 
> {{buildMessageFormat}}, while {{DefaultTextProvider}} builds a fresh instance 
> per call. {{MessageFormat}} is not thread-safe, so callers rendering the same 
> message concurrently format through one shared instance.
> h2. Current behaviour
> {{buildMessageFormat}} returns the cached instance on a hit and 
> {{formatWithNullDetection}} calls {{format()}} on it directly. The provider 
> is a singleton bean, so the cache and every instance in it are shared 
> application-wide. The sibling {{DefaultTextProvider.getText}} constructs a 
> new {{MessageFormat}} on each call.
> A pattern carrying a date or time sub-format delegates to a 
> {{SimpleDateFormat}} held by the {{MessageFormat}}, which keeps per-call 
> state in its {{Calendar}}; concurrent {{format()}} calls on the shared 
> instance can render the wrong argument or throw. Number and choice 
> sub-formats and plain placeholders are not affected on current JDKs.
> h2. Proposed change
> Keep the cache, but have {{buildMessageFormat}} return a clone of the cached 
> instance, so the cached entry is only ever a template and is never formatted 
> directly. {{MessageFormat.clone()}} deep-copies its sub-formats. This 
> preserves the pattern-parsing cache the WW-5540 work relies on; measured 
> against a fresh instance per call and against synchronizing on the shared 
> instance, cloning is the cheapest of the three.
> h2. Compatibility notes
> No configuration or API change. Descendant classes that override 
> {{buildMessageFormat}} keep their current behaviour; only the base 
> implementation changes.
> Applies to both maintenance lines.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to