On Mon, Apr 13, 2015 at 5:25 PM, Christopher Schultz < ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Leo, > > The good news is that you are thinking about this in the correct way: > that requests are handled by (usually) one thread and you have to > clean the ThreadLocal in the correct thread, otherwise Bad Things can > happen. > > Unfortunately, the one-thread-per-request scheme only works for > certain types of requests. If you are using WebSocket, Comet, etc. > then that can fall apart on you. > > Back to your use-case. A ServletRequestListener itself isn't > absolutely required, but it probably makes the most sense > architecturally: the infrastructure is already there for you, and the > behavior is orthogonal to the actual work you are trying to accomplish. > > It's not clear to me exactly what you are proposing above, but if it > matches the semantics of the ServletRequestListener, then it sounds > okay to me. > > - -chris > > The scenario I was proposing is more work than just implementing the ServletRequestListener. One thread local variable was being created in each filter. In my previous scenario, I was going to remove thread locals in the web service methods, but then realized I could remove them in the finally block of the filters on the request's way back out the chain(s). I think I prefer the Listener approach better.