~business code (simplified): public void myBusiness(AsyncResponse wrapperOfAsyncContext) { new Thread() { @Override public void run() { wrapperOfAsyncContext.synchronizedDispatch(); } }.start(); wrapperOfAsyncContext.synchronizedMethod(); }
If timing is good (and encountered enough to say it is in real life) then both method call will lock cause: 1. for the user thread: the dispatch call will call pauseNonContainerThread to wait the myBusiness thread to end (actually a bit more but you get the idea) 2. synchronizedMethod will lock on synchronizedDispatch so synchronizedMethod is lock on synchronizedDispatch which is lock on the pauseNonContainerThread of the caller/http thread so both threads are locked. Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2016-09-02 16:33 GMT+02:00 Mark Thomas <ma...@apache.org>: > On 02/09/2016 14:45, Romain Manni-Bucau wrote: > > PS: this pauseNonContainerThread breaks CXF apps cause they synchronize > an > > instance (AsyncResponseImpl) which potentially deadlock with tomcat cause > > of that. Would be nice to solve it in a manner not requiring all > apps/libs > > to know that. > > Can you provide more details of what is going on in this case? I can see > potential ways for this to break but the app has to do some pretty odd > things to make that possible. > > Mark > > > Romain Manni-Bucau > > @rmannibucau <https://twitter.com/rmannibucau> | Blog > > <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog > > <http://rmannibucau.wordpress.com> | Github <https://github.com/ > rmannibucau> | > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber > > <http://www.tomitribe.com> | JavaEE Factory > > <https://javaeefactory-rmannibucau.rhcloud.com> > > > > 2016-08-17 15:55 GMT+02:00 Romain Manni-Bucau <rmannibu...@gmail.com>: > > > >> Hi guys, > >> > >> I got several cases in prod where pauseNonContainerThread() get stucked > >> (ie the thread is blocked but no other thread is actually working and > can > >> release it). > >> > >> I'm not really sure of the cause - I suspect some timeouts but can't > >> guarantee it. Just for information I'm using JAX-RS 2 @Suspended with > CXF > >> which is built on top of Servlet 3 AsyncContext. > >> > >> Question is: can tomcat kind of enforce it to be released either using a > >> configurable timeout for this wait or something equivalent to avoid > such a > >> case? Goal is to avoid as much as possible to fully lock the container > in > >> the caller doesn't handle properly the async usage (hypothesis being > tomcat > >> doesn't have a bug on that area). > >> > >> > >> Romain Manni-Bucau > >> @rmannibucau <https://twitter.com/rmannibucau> | Blog > >> <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog > >> <http://rmannibucau.wordpress.com> | Github > >> <https://github.com/rmannibucau> | LinkedIn > >> <https://www.linkedin.com/in/rmannibucau> | Tomitriber > >> <http://www.tomitribe.com> | JavaEE Factory > >> <https://javaeefactory-rmannibucau.rhcloud.com> > >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > >