ok, here is proposed solutions.
1. Move deploy to separate thread and have timeout functionality in main thread. That mean when timeout is passed and ping URL still cannot be accessed main thread interrupts child thread with deploy. I use here for this thread.interrupt() method. This part is listed in patch1.txt file but unfortunately this is not working code and when Tomcat hangs up I have two threads hang up as well. Perhaps threads guru could advice here something.
2. Leave current timeout functionlity as it's in the same thread and after deploy and have setReadTimeout for HttpUrlConnection object in TomcatManager. This code attached in patch2.txt. I setup there 300000 ms as timeout for read data that means if during 5 minuts action will not be finished then it will be failed.
As I think the goal of current timeout functionality to monitor the application that it can be accessible AFTER deployment and the goal of just introduced timeout is see if tomcat action can be performed in specified timeout.
Also probably better to make readTimeout item configurable.
Also probably somebody has something which could help to track tomcat states like for example if tomcat has deployment in progress?