Scoped variables
Jon Harper
jon.harper87 at gmail.com
Thu Jul 11 15:53:22 UTC 2019
Hi list,
I read with much interest the "scoped variable" discussion from
December 2018: https://mail.openjdk.java.net/pipermail/loom-dev/2018-December/thread.html
Towards the end of the conversation, the following was stated:
> dean.long at oracle.com ; 12/7/18 1:15 PM
> Now might be a good time to start a discussion on how we want scoped variables to be created and named.
> Doug Lea dl at cs.oswego.edu ; Sun Dec 9 14:32:07 UTC 2018
> Or backing up further, how about a discussion of use cases that should be covered?
Has this been done and is there a link to a conclusion ?
My favorite use case is implementing what various logging frameworks
call Diagnostic Contexts in a way that is safe for everyone, whether
they use threads manually or abstracted behind Executors (or using
loom's fibers). I think the current agreement is that Diagnostic
Contexts are too dangerous (currently implemented with threadlocals)
because they can spill from one context to another when using
Executors, resulting in false logs. Logs are a prime example where you
don't want to explicitly pass a context object everywhere but still
want your logs to display contextual informations (like a request id).
This is especially true when you want to add a new log somewhere in
the code where the context is not passed and you have to backtrack all
the call chain and add the context object to all the intermediate
method arguments.
Cheers,
Jon
More information about the loom-dev
mailing list