Project: Tomcat
Bug 53450 Deployment of an application with 'ROOT' context hangs forever
Reported: 2012-06-21 18:22:10 | Status: resolved fixed

Hi, The scenario is the following: - I have running Tomcat 7.0.28 - I deploy an application with 'ROOT' context - The deployment hangs forever. When taking a tread dump, the following is suspicious: "localhost-startStop-2" daemon prio=6 tid=0x0000000006607800 nid=0x2560 waiting on condition [0x0000000009ebf000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007d80f0108> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178) at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:807) at org.apache.catalina.core.ContainerBase.removeContainerListener(ContainerBase.java:1071) at org.apache.catalina.core.StandardEngine$AccessLogListener.uninstall(StandardEngine.java:463) at org.apache.catalina.core.StandardEngine$AccessLogListener.containerEvent(StandardEngine.java:505) at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1431) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:907) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) As you can see - A read lock is acquired at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1425) - Then every listener is invoked to process the container event - Then AccessLogListener is invoked org.apache.catalina.core.StandardEngine$AccessLogListener.uninstall(StandardEngine.java:463) - The latter causes a call for a write lock org.apache.catalina.core.ContainerBase.removeContainerListener(ContainerBase.java:1071) - Unfortunately in the ReentrantReadWriteLock it is stated that upgrade from read to write lock is not possible "Reentrancy also allows downgrading from the write lock to a read lock, by acquiring the write lock, then the read lock and then releasing the write lock. However, upgrading from a read lock to the write lock is not possible." Regards Violeta Georgieva

Files changed in fix:
java/org/apache/catalina/core/ContainerBase.java