Author: craigmcc
Date: Thu Oct 21 22:48:39 2004
New Revision: 55309

Modified:
   
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesRequestProcessor.java
   
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesTilesRequestProcessor.java
Log:
Refine the context.release() patch from Piero Colagrosso.  We must call
context.release() *only* if we were the ones that actually created a new
FacesContext.  Otherwise, the context object will be released twice (once
by us, and once by the JSF runtime) with undefined results -- with the
JSF RI, for example, this combination triggers an IllegalStateException
error in the servlet container's logs.

Also, applied the same mechanism to the non-Tiles request processor as well,
to avoid the potential for creating dangling FacesContext instances that are
never cleaned up.


Modified: 
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesRequestProcessor.java
==============================================================================
--- 
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesRequestProcessor.java
      (original)
+++ 
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesRequestProcessor.java
      Thu Oct 21 22:48:39 2004
@@ -120,6 +120,7 @@
             FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         Lifecycle lifecycle = // FIXME - alternative lifecycle ids
             lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+        boolean created = false;
         FacesContext context = FacesContext.getCurrentInstance();
         if (context == null) {
             if (log.isTraceEnabled()) {
@@ -148,10 +149,16 @@
             log.trace("  Rendering view for '" + uri + "'");
         }
         lifecycle.render(context);
-        if (log.isTraceEnabled()) {
-            log.trace("  Marking request complete for '" + uri + "'");
+        if (created) {
+            if (log.isTraceEnabled()) {
+                log.trace("  Releasing context for '" + uri + "'");
+            }
+            context.release();
+        } else {
+            if (log.isTraceEnabled()) {
+                log.trace("  Rendering completed");
+            }
         }
-        context.responseComplete();
 
     }
 

Modified: 
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesTilesRequestProcessor.java
==============================================================================
--- 
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesTilesRequestProcessor.java
 (original)
+++ 
struts/trunk/struts-faces/core-library/src/java/org/apache/struts/faces/application/FacesTilesRequestProcessor.java
 Thu Oct 21 22:48:39 2004
@@ -120,6 +120,7 @@
             FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         Lifecycle lifecycle = // FIXME - alternative lifecycle ids
             lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+        boolean created = false;
         FacesContext context = FacesContext.getCurrentInstance();
         if (context == null) {
             if (log.isTraceEnabled()) {
@@ -129,7 +130,8 @@
                 FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
             HttpServletRequestWrapper wrapper = new 
HttpServletRequestWrapper(request, uri);
             context = fcf.getFacesContext(servlet.getServletContext(), wrapper,
-                                          response, lifecycle); 
+                                          response, lifecycle);
+            created = true;
         }
 
         // Create a new view root
@@ -144,11 +146,30 @@
             log.trace("  Rendering view for '" + uri + "'");
         }
         lifecycle.render(context);
+        if (created) {
+            if (log.isTraceEnabled()) {
+                log.trace("  Releasing context for '" + uri + "'");
+            }
+            context.release();
+        } else {
+            if (log.isTraceEnabled()) {
+                log.trace("  Rendering completed");
+            }
+        }
+
+    }
+
+
+    // Override default processing to provide logging
+    protected void internalModuleRelativeForward
+        (String uri, HttpServletRequest request, HttpServletResponse response)
+        throws IOException, ServletException {
+
         if (log.isTraceEnabled()) {
-            log.trace("  Marking request complete for '" + uri + "'");
+            log.trace("Performing internal module relative forward to '" +
+                      uri + "'");
         }
-        // context.responseComplete();
-        context.release();
+        super.internalModuleRelativeForward(uri, request, response);
 
     }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to