java - How to force Apache Tomcat not to reuse a thread from the thread pool? -
we've got normal-ish server stack including blazeds, tomcat , hibernate.
we'd arrange things such if errors (especially assertionerror) thrown, current thread considered in unknown state , won't used further http requests. (partly because we're storing things, such hibernate transaction session, in thread-local storage. now, can catch throwables , make sure roll transactions , rethrow, there's no guarantee other code may have left knows in thread-local storage.)
tomcat default thread pool behavior reuses threads. tried specifying our own executor, seems specific method of changing thread pool behavior, doesn't call executor.execute() new task each request. (most reuses same execution context requests in same http connection.)
one option disable keepalive, there's 1 request per http connection, that's ugly.
anyway, i'd know. there way tell tomcat not reuse thread, or kill or exit thread tomcat forced create new one?
(from tomcat source, appears tomcat close connection , abandon task/thread after sending http 500 response, don't know how blazeds generate 500 response; that's angle i'd know more about.)
i suggest getting rid of use of thread-local storage, or @ least coming method clear thread-local storage when request first enters pipeline (with <filter> in web.xml, example).
having reconfigure basic tomcat work app points code smell.
Comments
Post a Comment