[jira] [Resolved] (VELTOOLS-198) org.apache.velocity.tools.ConversionUtils#getNumberFormat(java.lang.String, java.util.Locale) is not thread safe for custom formats
"Claude Brisson (Jira)" <[email protected]> Wed, 17 Jun 2026 14:29:00 +0000 (UTC)
| Newsgroups | gmane.comp.jakarta.velocity.devel |
|---|---|
| Message-ID | <[email protected]> |
[ https://issues.apache.org/jira/browse/VELTOOLS-198?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claude Brisson resolved VELTOOLS-198.
-------------------------------------
Fix Version/s: 3.2
4.0
Assignee: Claude Brisson
Resolution: Fixed
> org.apache.velocity.tools.ConversionUtils#getNumberFormat(java.lang.String, java.util.Locale) is not thread safe for custom formats
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: VELTOOLS-198
> URL: https://issues.apache.org/jira/browse/VELTOOLS-198
> Project: Velocity Tools
> Issue Type: Bug
> Components: GenericTools
> Affects Versions: 3.1
> Reporter: Oscar Doral
> Assignee: Claude Brisson
> Priority: Major
> Labels: pull-request-available
> Fix For: 3.2, 4.0
>
>
> org.apache.velocity.tools.ConversionUtils holds a cache for custom formats so it can reuse formatters across different requests:
> {code:java}
> private static ConcurrentMap<String,NumberFormat> customFormatsCache = new ConcurrentHashMap<String,NumberFormat>(); {code}
> Problem is formatters don't use to be thread safe so if same formatter is used at the same time by two different threads we can get errors depending on race conditions.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)