Should ScopedValue even allow null?

Pedro Lamarão pedro.lamarao at prodist.com.br
Thu Jan 30 16:29:44 UTC 2025


Em qui., 30 de jan. de 2025 às 13:21, Adam Gent <me at adamgent.com> escreveu:

> I had assumed for an embarrassing amount of time that ScopedValue would
> not allow null. So much so that I could not understand why its API looked
> like Optional.
>
> Given that ScopedValue goals are to make things easier it seems that not
> allowing null might be helpful.
>
> Thoughts?
>
> (Alan had mentioned on reddit that this topic was OK and I assume I'm
> posting in the right place. If not advance apologies.)
>

Hi Adam!
One of the "classic" examples for ScopedValues is communicating the
Principal associated with a session in some framework.
Should we require that frameworks must, for anonymous sessions, set the
Principal to some NoPrincipal object instead of null?

-- 
Pedro Lamarão
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250130/6144e0f2/attachment-0001.htm>


More information about the loom-dev mailing list