ScopedValue.runWhere not returning scope

Pedro Lamarão pedro.lamarao at prodist.com.br
Fri Jun 7 14:52:16 UTC 2024


Em sex., 7 de jun. de 2024 às 10:05, Marcin Grzejszczak <
marcin.grzejszczak at gmail.com> escreveu:


> > Can you explain that a little more? Why can't isolated functionality be
> added without separate before and after logic?
>
> I mentioned that above but I'll try to rephrase it. There are already
> solutions such as Apache CXF [1], Apache Commons for Http client [2],
> Datasource Proxy [3], Jersey [4][5], R2DbcProxy [6] that work with such
> interceptors. All that code would have to be rewritten. I'm not saying that
> this is not feasible but let's be realistic. Also if all of those libraries
> wouldn't rewrite their code then distributed tracing would be broken. If
> one service is not working then instead of one correlation you will get two
> or more.
>

In AspectJ`s terms, interceptors such as these are equivalent to before and
after advice.
To enable something like a ScopedValueInterceptor, it seems to me
sufficient to extend this scheme to include around advices.
The handler of AroundInterceptors would pass a proceed object to the around
advice.
ScopedValueAroundInterceptor would do whatever it wants to do, call
scopedValue.runWhere, then call proceed inside that scope.
If a design like this was deemed overkill before, perhaps its time has
arrived.

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


More information about the loom-dev mailing list