jamesfredley commented on PR #15797:
URL: https://github.com/apache/grails-core/pull/15797#issuecomment-4847081572
@jdaugherty I checked the history and current usage.
`ConvertersConfigurationHolder` has effectively been the singleton app-level
holder since the converter configuration holder was introduced: it owns the
default configuration and the named configurations for JSON/XML.
The `ThreadLocal` is not the app-wide store for those definitions. It is the
per-execution override used by `JSON.use('name') { ... }` / `XML.use('name') {
... }`, and by `JSON.use('name')` / `XML.use('name')`, to select a named
converter configuration for the current rendering path without changing the
global default.
If the active converter config were only a singleton/global, a scoped call
like `JSON.use('deep') { ... }` would temporarily change converter behavior
process-wide. Concurrent requests or async rendering paths could then observe
the wrong marshaller set, pretty-print setting, circular-reference behavior,
etc. The ThreadLocal keeps that selected active config isolated to the current
execution while the singleton holder still supplies the shared defaults and
named configs.
So this PR is not introducing ThreadLocal state or changing that contract.
It keeps the existing default/named singleton model, but makes the
current-thread override cheaper and safer for virtual-thread usage by not
allocating an empty map for default lookups and by removing the ThreadLocal
entry once scoped state is cleared.
--
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]