You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/03/13 20:43:41 UTC

svn commit: r1300302 - in /myfaces/core/branches/2.0.x: api/src/main/java/javax/faces/component/UIViewRoot.java impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java

Author: lu4242
Date: Tue Mar 13 19:43:40 2012
New Revision: 1300302

URL: http://svn.apache.org/viewvc?rev=1300302&view=rev
Log:
MYFACES-3199 Handling AbortProcessingException is unconsistent (catch other Exception instance (non APE) ,publish them as ExceptionQueuedEvent and short-circuit broadcast to ensure source component available within exceptionQueuedEventContext.getComponent() ) (Thanks to Martin Koci for provide this patch)

Modified:
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java?rev=1300302&r1=1300301&r2=1300302&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIViewRoot.java Tue Mar 13 19:43:40 2012
@@ -1024,12 +1024,6 @@ public class UIViewRoot extends UICompon
             }
             catch (Exception e)
             {
-                // for any other exception publish ExceptionQueuedEvent
-                // publish the Exception to be handled by the ExceptionHandler
-                // to publish or to not publish APE? That is the question : MYFACES-3199 
-                ExceptionQueuedEventContext exceptionContext 
-                        = new ExceptionQueuedEventContext(context, e, source, context.getCurrentPhaseId());
-                context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, exceptionContext);
 
                 Throwable cause = e;
                 AbortProcessingException ape = null;
@@ -1044,6 +1038,19 @@ public class UIViewRoot extends UICompon
                 }
                 while (cause != null);
                 
+                // for any other exception publish ExceptionQueuedEvent
+                // publish the Exception to be handled by the ExceptionHandler
+                // to publish or to not publish APE? That is the question : MYFACES-3199. We publish it,
+                // because user can handle it in custom exception handler then. 
+                if (ape != null)
+                {
+                    e = ape;
+                }
+                ExceptionQueuedEventContext exceptionContext 
+                        = new ExceptionQueuedEventContext(context, e, source, context.getCurrentPhaseId());
+                context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, exceptionContext);
+
+                
                 if (ape != null)
                 {
                     // APE found,  abortion for this event only

Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java?rev=1300302&r1=1300301&r2=1300302&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/ExceptionTestCase.java Tue Mar 13 19:43:40 2012
@@ -142,7 +142,10 @@ public class ExceptionTestCase extends F
         {
             return;
         }
-        Assert.fail("Exception should be thrown at this point.");
+        Iterable<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents();
+        ExceptionQueuedEvent exceptionQueuedEvent = unhandledExceptionQueuedEvents.iterator().next();
+         
+        Assert.assertNotNull(exceptionQueuedEvent.getContext().getException(), "Exception should be queued at this point.");
     }
     
     /**
@@ -178,7 +181,10 @@ public class ExceptionTestCase extends F
         {
             return;
         }
-        Assert.fail("Exception should be thrown at this point.");
+        Iterable<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents();
+        ExceptionQueuedEvent exceptionQueuedEvent = unhandledExceptionQueuedEvents.iterator().next();
+         
+        Assert.assertNotNull(exceptionQueuedEvent.getContext().getException(), "Exception should be queued at this point.");
     }
 
     @Test