Thanks Alan,

That's quite interesting.   Often we use Executor tasks to perform event notifications to listeners, context is the same across many, in fact we do this for distributed garbage collection over TLS connections too.

--
Regards,
Peter

On 16/06/2023 3:48 pm, Alan Bateman wrote:
On 16/06/2023 03:48, Peter Firmstone wrote:
:

As it isn't yet clear how a Subject context will be preserved across threads in future version of OpenJDK, (currently we use the AccessControlContext for that), for example we capture the existing context, to establish TLS connections in call back communications for network event listeners.


It's good to think about a Subject.current/callAs re-implemented to use ScopedValue [1], currently in preview with JEP 446 in Java 21. ScopedValue allows for sharing in structured concurrency contexts.

-Alan

[1] https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.html
[2] https://openjdk.org/jeps/446

Reply via email to