Yes. I noticed that. :)
I was only testing with the ByteCounter example that comes with tomcat.That
example uses nio, so there's no new thread. As soon as I use...
```
val ac = req.startAsync();
ac.start(() -> {
// <logic in here>
});
```
The runnable does not get the threadlocal, obviously. :)
Thanks for the feedback Chris!
[]s,
Thiago.
On Tue, Mar 9, 2021 at 3:03 PM Christopher Schultz <
[email protected]> wrote:
> Thiago,
>
> On 3/9/21 08:17, Thiago Veronezi wrote:
> > I have a java agent that has its own transaction feature and it does it
> by
> > using Threadlocals. The agent transactions feature seems to work ok with
> > Tomcat async requests.
> >
> > Does anyone know it's fine to use threadlocals on async requests?
>
> It's definitely *not* fine to use ThreadLocal with asynchronous
> requests. If it's working for you, its only due to some very lucky
> circumstances.
>
> If you need to store information between invocations of IO callbacks,
> you will need to store that information in the request/response objects.
>
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>