Feb 22nd, 2012, 08:44 AM
How is SimpleThreadScope cleared in a web container?
I'm looking at using the SimpleThreadScope in a JAX-WS WebService as I feel it most closely matches my needs. Given that it is a WebService, I am not comfortable using the Request scope given that there is no real concept of a request in the service.
My question, however, is how Spring handles the clearing the scope. Given that this is a web container, the thread is never officially terminated, but rather returned to the pool at the end of the request. Consequently, I fear that the Thread scoped objects will not be cleared out and will find myself with a memory leak.
I've looked at the more involved CustomThreadScopeModule (http://www.springbyexample.org/examp...pe-module.html) but do not understand that one any better. In either case, there needs to be a trigger to clear the object from the ThreadLocal object prior to returning the thread to the pool, but I cannot seem to see it.
Can anyone help clarify please?
Tags for this Thread