Comments on: Scoped Values in Java – What They Are and How to Use Them https://www.happycoders.eu/java/scoped-values/ Mon, 07 Apr 2025 11:12:12 +0000 hourly 1 By: Sven Woltmann https://www.happycoders.eu/java/scoped-values/#comment-19436 Fri, 29 Sep 2023 08:55:20 +0000 https://www.happycoders.eu/?p=34216#comment-19436 In reply to franky.

Hi Franky, you're right. Thanks for pointing this out. I've corrected it now.

]]>
By: franky https://www.happycoders.eu/java/scoped-values/#comment-19345 Fri, 22 Sep 2023 13:00:25 +0000 https://www.happycoders.eu/?p=34216#comment-19345 I think you have a dot too much in the tructured task example
at
Future. dataFuture

]]>
By: Sven Woltmann https://www.happycoders.eu/java/scoped-values/#comment-17647 Wed, 01 Feb 2023 20:30:02 +0000 https://www.happycoders.eu/?p=34216#comment-17647 In reply to Roie Beck.

Hi Roie,

such a change would have to be implemented in the Spring Framework itself (like in the "Server" class above). In the Spring Source code, there's probably a place where the ObjectMapper is created (or a producer bean is invoked to create the ObjectMapper). At that place, a scope would have to be opened, and the request handler would have to be invoked within the run() method.

Then from every code called within the scope's run() method, you could access the OM via the static ScopedValue field's get() method (or some more convenient accessor) provided by the framework.

That's my assumption without deeper knowledge of how the Spring framework works internally. A Spring framework developer could probably give you a more precice answer.

Best wishes
Sven

]]>
By: Roie Beck https://www.happycoders.eu/java/scoped-values/#comment-17605 Mon, 16 Jan 2023 18:52:49 +0000 https://www.happycoders.eu/?p=34216#comment-17605 Hi Sven, first thank for a great article, a question if I may, one of the main reason for a spring developer to use threadLocal is the infamous ObjectMapper with its heavy constructor, so by wrapping the OM in TL var the servlet threads will have it and will not need to re-build it every time, how would you achieve the same effect with a ScopeValue variable? Keep in mind OM can be access from multiple locations during the rest call

]]>