You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/06/11 09:39:02 UTC

svn commit: r666552 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java

Author: skitching
Date: Wed Jun 11 00:39:02 2008
New Revision: 666552

URL: http://svn.apache.org/viewvc?rev=666552&view=rev
Log:
In deinit, handle case where init failed.

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java?rev=666552&r1=666551&r2=666552&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java Wed Jun 11 00:39:02 2008
@@ -38,8 +38,9 @@
  */
 class ContextLockRequestHandler implements RequestHandler
 {
-    private ConversationContext context;
     private Log log = LogFactory.getLog(ContextLockRequestHandler.class);
+    private ConversationContext context;
+    private boolean lockAcquired = false;
 
     public void init(FacesContext facesContext) throws FacesException
     {
@@ -88,6 +89,7 @@
                             log.debug("Locking context " + context.getId());
                         }
                         context.lockInterruptablyForCurrentThread();
+                        lockAcquired = true;
                     }
                     catch(InterruptedException e)
                     {
@@ -110,11 +112,20 @@
     {
         if (context != null)
         {
-            if (log.isDebugEnabled())
+            if (lockAcquired == true)
+            {
+                if (log.isDebugEnabled())
+                {
+                    log.debug("Unlocking context " + context.getId());
+                }
+                context.unlockForCurrentThread();
+            }
+            else
             {
-                log.debug("Unlocking context " + context.getId());
+                log.debug(
+                  "Odd situation: lock never acquired. Perhaps InterruptedException occurred"
+                  + " while waiting to get the context lock?");
             }
-            context.unlockForCurrentThread();
         }
     }