Author: mstruk
Date: 2011-05-19 10:59:34 -0400 (Thu, 19 May 2011)
New Revision: 6501
Modified:
sandbox/as7_support/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
Log:
Fix for deadlocks upon concurrent Context shutdowns - JBoss AS7 starts up and shuts down
.wars concurrently
Modified:
sandbox/as7_support/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
===================================================================
---
sandbox/as7_support/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2011-05-19
14:57:33 UTC (rev 6500)
+++
sandbox/as7_support/wci/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2011-05-19
14:59:34 UTC (rev 6501)
@@ -354,27 +354,37 @@
{
throw new IllegalStateException("Disposed registration");
}
- synchronized (container.lock)
+
+ if (webAppId == null)
{
- if (webAppId == null)
- {
- throw new IllegalArgumentException("No null web app id
accepted");
- }
+ throw new IllegalArgumentException("No null web app id accepted");
+ }
- //
- WebAppImpl webApp = container.webAppMap.remove(webAppId);
- if (webApp != null)
+ WebAppImpl webApp = container.webAppMap.get(webAppId);
+ if (webApp == null)
+ {
+ log.debug("Web application " + webAppId + " was not
registered");
+ return false;
+ }
+ // lock context before locking container to prevent deadlocks
+ synchronized (webApp.context)
+ {
+ synchronized (container.lock)
{
- log.debug("Web application " + webAppId + "
cleanup");
- container.fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED));
- webApp.context.stop();
- return true;
+ webApp = container.webAppMap.remove(webAppId);
+ if (webApp != null)
+ {
+ log.debug("Web application " + webAppId + "
cleanup");
+ container.fireEvent(new WebAppLifeCycleEvent(webApp,
WebAppLifeCycleEvent.REMOVED));
+ webApp.context.stop();
+ return true;
+ }
+ else
+ {
+ log.debug("Web application " + webAppId + " was not
registered");
+ return false;
+ }
}
- else
- {
- log.debug("Web application " + webAppId + " was not
registered");
- return false;
- }
}
}