Usage of Virtual Threads and ScopedValue
Alan Bateman
alan.bateman at oracle.com
Wed Aug 20 10:30:24 UTC 2025
On 20/08/2025 06:21, Peter Firmstone wrote:
> :
>
> It uses a heavily modified Authorization implementation ...
>
> Basically ScopedValue is used to detect and limit recursion, which can
> occur when a permission check requires other permission checks to
> complete. The implementation is relatively basic, but it works well,
> eg, for more info see the link above.
>
>
ScopedValue is a good choice for authorization as the current "security
context" or "identity" is an implicit method parameter. In the JDK, the
Subject API was recently re-implemented to use a scoped value.
Detecting reentrancy, or limiting recursion in your example, is another
good usage. In the JDK there are several cases, provider
lookup/discovery in particular, where reentrancy needs to be detected.
One of these (Charset) was recently changed to detect reentrancy based
on whether a ScopedValue a bound or not.
Experience using ScopedValue is always useful. If you have feedback or
experience to report then bringing it to the loom-dev list would be best.
-Alan
More information about the discuss
mailing list