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/05/22 17:47:26 UTC

svn commit: r1341542 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/ impl/src/main/java/org/apache/myfaces/application/ impl/src/main/java/org/apache/myfaces/view/facelets/compiler/ shared/src/main/java/org/apache/myfaces/shared/rend...

Author: lu4242
Date: Tue May 22 15:47:26 2012
New Revision: 1341542

URL: http://svn.apache.org/viewvc?rev=1341542&view=rev
Log:
MYFACES-3501 Remove unncecessary exception wrapping (thanks to Martin Koci for provide this patch)

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextInstruction.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=1341542&r1=1341541&r2=1341542&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java Tue May 22 15:47:26 2012
@@ -398,38 +398,25 @@ public abstract class UIComponentBase ex
         {
             throw new NullPointerException("event");
         }
-        try
+        
+        if (event instanceof BehaviorEvent && event.getComponent() == this)
         {
-            if (event instanceof BehaviorEvent && event.getComponent() == this)
-            {
-                Behavior behavior = ((BehaviorEvent) event).getBehavior();
-                behavior.broadcast((BehaviorEvent) event);
-            }
-            
-            if (_facesListeners == null)
-            {
-                return;
-            }
-            // perf: _facesListeners is RandomAccess instance (javax.faces.component._DeltaList)
-            for (int i = 0, size = _facesListeners.size(); i < size; i++)
-            {
-                FacesListener facesListener = _facesListeners.get(i);
-                if (event.isAppropriateListener(facesListener))
-                {
-                    event.processListener(facesListener);
-                }
-            }
+            Behavior behavior = ((BehaviorEvent) event).getBehavior();
+            behavior.broadcast((BehaviorEvent) event);
+        }
+
+        if (_facesListeners == null)
+        {
+            return;
         }
-        catch (Exception ex)
+        // perf: _facesListeners is RandomAccess instance (javax.faces.component._DeltaList)
+        for (int i = 0, size = _facesListeners.size(); i < size; i++)
         {
-            if (ex instanceof AbortProcessingException)
+            FacesListener facesListener = _facesListeners.get(i);
+            if (event.isAppropriateListener(facesListener))
             {
-                throw (AbortProcessingException) ex;
+                event.processListener(facesListener);
             }
-            String location = getComponentLocation(this);
-            throw new FacesException("Exception while calling broadcast on component : " 
-                    + getPathToComponent(this) 
-                    + (location != null ? " created from: " + location : ""), ex);
         }
     }
     

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java?rev=1341542&r1=1341541&r2=1341542&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java Tue May 22 15:47:26 2012
@@ -18,16 +18,13 @@
  */
 package org.apache.myfaces.application;
 
-import javax.el.ELException;
 import javax.el.MethodExpression;
-import javax.faces.FacesException;
 import javax.faces.application.Application;
 import javax.faces.application.NavigationHandler;
 import javax.faces.component.ActionSource;
 import javax.faces.component.ActionSource2;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
 import javax.faces.el.MethodBinding;
 import javax.faces.event.AbortProcessingException;
 import javax.faces.event.ActionEvent;
@@ -67,94 +64,25 @@ public class ActionListenerImpl implemen
         if (methodExpression != null)
         {
             fromAction = methodExpression.getExpressionString();
-            try
-            {
-                Object objOutcome = methodExpression.invoke(facesContext.getELContext(), null);
-                if (objOutcome != null)
-                {
-                    outcome = objOutcome.toString();
-                }
-            }
-            catch (ELException e)
-            {
-                // "... If that fails for any reason, throw an AbortProcessingException,
-                // including the cause of the failure ..."
-                // -= Leonardo Uribe =- after discussing this topic on MYFACES-3199,
-                // the conclusion is the part is an advice
-                // for the developer implementing a listener in a method expressions
-                // that could be wrapped by this class.
-                // The spec wording is poor but, to keep this coherently with
-                // ExceptionHandler API, the spec and code on UIViewRoot we need:
-                // 2a) "exception is instance of APE or any of the causes of
-                // the exception are an APE,
-                // DON'T publish ExceptionQueuedEvent and terminate processing for current event".
-                // 2b) for any other exception publish ExceptionQueuedEvent and continue broadcast processing.
-                Throwable cause = e.getCause();
-                AbortProcessingException ape = null;
-                if (cause != null)
-                {
-                    do
-                    {
-                        if (cause != null && cause instanceof AbortProcessingException)
-                        {
-                            ape = (AbortProcessingException) cause;
-                            break;
-                        }
-                        cause = cause.getCause();
-                    }
-                    while (cause != null);
-                }
-                
-                if (ape != null)
-                {
-                    // 2a) "exception is instance of APE or any of the causes of the exception are an APE, 
-                    // DON'T publish ExceptionQueuedEvent and terminate processing for current event".
-                    // To do this throw an AbortProcessingException here, later on UIViewRoot.broadcastAll,
-                    // this exception will be received and stored to handle later.
-                    throw ape;
-                }
-                
-                // Since this ActionListener is the one who handles navigation, if we have another different exception
-                // here we can't queue it on ExceptionHandler stack, instead throw it as a FacesException.
-                throw new FacesException("Error calling action method of component with id "
-                                         + actionEvent.getComponent().getClientId(facesContext), e);
-            }
-            catch (RuntimeException e)
+
+            Object objOutcome = methodExpression.invoke(facesContext.getELContext(), null);
+            if (objOutcome != null)
             {
-                throw new FacesException("Error calling action method of component with id "
-                                         + actionEvent.getComponent().getClientId(facesContext), e);
+                outcome = objOutcome.toString();
             }
+            
         }
         
         else if (methodBinding != null)
         {
             fromAction = methodBinding.getExpressionString();
-            try
-            {
-                Object objOutcome = methodBinding.invoke(facesContext, null);
+            Object objOutcome = methodBinding.invoke(facesContext, null);
 
-                if (objOutcome != null)
-                {
-                    outcome = objOutcome.toString();
-                }
-            }
-            catch (EvaluationException e)
+            if (objOutcome != null)
             {
-                Throwable cause = e.getCause();
-                if (cause != null && cause instanceof AbortProcessingException)
-                {
-                    throw (AbortProcessingException)cause;
-                }
-   
-                throw new FacesException("Error calling action method of component with id "
-                                         + actionEvent.getComponent().getClientId(facesContext), e);
-                
-            }
-            catch (RuntimeException e)
-            {
-                throw new FacesException("Error calling action method of component with id "
-                                         + actionEvent.getComponent().getClientId(facesContext), e);
+                outcome = objOutcome.toString();
             }
+
         }
         
         NavigationHandler navigationHandler = application.getNavigationHandler();

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextInstruction.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextInstruction.java?rev=1341542&r1=1341541&r2=1341542&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextInstruction.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextInstruction.java Tue May 22 15:47:26 2012
@@ -21,7 +21,6 @@ package org.apache.myfaces.view.facelets
 import java.io.IOException;
 
 import javax.el.ELContext;
-import javax.el.ELException;
 import javax.el.ExpressionFactory;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
@@ -43,19 +42,7 @@ final class TextInstruction implements I
     public void write(FacesContext context) throws IOException
     {
         ResponseWriter out = context.getResponseWriter();
-        try
-        {
-            txt.writeText(out, context.getELContext());
-            // out.writeText(txt.toString(elContext), null);
-        }
-        catch (ELException e)
-        {
-            throw new ELException(this.alias + ": " + e.getMessage(), e.getCause());
-        }
-        catch (Exception e)
-        {
-            throw new ELException(this.alias + ": " + e.getMessage(), e);
-        }
+        txt.writeText(out, context.getELContext());
     }
 
     public Instruction apply(ExpressionFactory factory, ELContext ctx)

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java?rev=1341542&r1=1341541&r2=1341542&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java Tue May 22 15:47:26 2012
@@ -292,106 +292,95 @@ public final class RendererUtils
     public static String getStringValue(FacesContext facesContext,
             UIComponent component)
     {
-        try
+        if (!(component instanceof ValueHolder))
         {
-            if (!(component instanceof ValueHolder))
-            {
-                throw new IllegalArgumentException("Component : "
-                        + getPathToComponent(component)
-                        + "is not a ValueHolder");
-            }
+            throw new IllegalArgumentException("Component : "
+                    + getPathToComponent(component)
+                    + "is not a ValueHolder");
+        }
 
-            if (component instanceof EditableValueHolder)
+        if (component instanceof EditableValueHolder)
+        {
+            Object submittedValue = ((EditableValueHolder) component)
+                    .getSubmittedValue();
+            if (submittedValue != null)
             {
-                Object submittedValue = ((EditableValueHolder) component)
-                        .getSubmittedValue();
-                if (submittedValue != null)
+                if (log.isLoggable(Level.FINE))
                 {
-                    if (log.isLoggable(Level.FINE))
-                    {
-                        log.fine("returning 1 '" + submittedValue + "'");
-                    }
-                    return submittedValue.toString();
+                    log.fine("returning 1 '" + submittedValue + "'");
                 }
+                return submittedValue.toString();
             }
+        }
 
-            Object value;
+        Object value;
 
-            if (component instanceof EditableValueHolder)
-            {
+        if (component instanceof EditableValueHolder)
+        {
 
-                EditableValueHolder holder = (EditableValueHolder) component;
+            EditableValueHolder holder = (EditableValueHolder) component;
 
-                if (holder.isLocalValueSet())
-                {
-                    value = holder.getLocalValue();
-                }
-                else
-                {
-                    value = getValue(component);
-                }
+            if (holder.isLocalValueSet())
+            {
+                value = holder.getLocalValue();
             }
             else
             {
                 value = getValue(component);
             }
+        }
+        else
+        {
+            value = getValue(component);
+        }
 
-            Converter converter = ((ValueHolder) component).getConverter();
-            if (converter == null && value != null)
-            {
+        Converter converter = ((ValueHolder) component).getConverter();
+        if (converter == null && value != null)
+        {
 
-                try
-                {
-                    converter = facesContext.getApplication().createConverter(
-                            value.getClass());
-                    if (log.isLoggable(Level.FINE))
-                    {
-                        log.fine("the created converter is " + converter);
-                    }
-                }
-                catch (FacesException e)
+            try
+            {
+                converter = facesContext.getApplication().createConverter(
+                        value.getClass());
+                if (log.isLoggable(Level.FINE))
                 {
-                    log.log(Level.SEVERE, "No converter for class "
-                            + value.getClass().getName()
-                            + " found (component id=" + component.getId()
-                            + ").", e);
-                    // converter stays null
+                    log.fine("the created converter is " + converter);
                 }
             }
-
-            if (converter == null)
+            catch (FacesException e)
             {
-                if (value == null)
-                {
-                    if (log.isLoggable(Level.FINE))
-                    {
-                        log.fine("returning an empty string");
-                    }
-                    return "";
-                }
+                log.log(Level.SEVERE, "No converter for class "
+                        + value.getClass().getName()
+                        + " found (component id=" + component.getId()
+                        + ").", e);
+                // converter stays null
+            }
+        }
 
+        if (converter == null)
+        {
+            if (value == null)
+            {
                 if (log.isLoggable(Level.FINE))
                 {
-                    log.fine("returning an .toString");
+                    log.fine("returning an empty string");
                 }
-                return value.toString();
-
+                return "";
             }
 
             if (log.isLoggable(Level.FINE))
             {
-                log.fine("returning converter get as string " + converter);
+                log.fine("returning an .toString");
             }
-            return converter.getAsString(facesContext, component, value);
+            return value.toString();
 
         }
-        catch (PropertyNotFoundException ex)
-        {
-            log.log(Level.SEVERE, "Property not found - called by component : "
-                    + getPathToComponent(component), ex);
 
-            throw ex;
+        if (log.isLoggable(Level.FINE))
+        {
+            log.fine("returning converter get as string " + converter);
         }
+        return converter.getAsString(facesContext, component, value);
     }
 
     public static String getStringFromSubmittedValueOrLocalValueReturnNull(
@@ -499,17 +488,7 @@ public final class RendererUtils
 
     private static Object getValue(UIComponent component)
     {
-        Object value;
-        try
-        {
-            value = ((ValueHolder) component).getValue();
-        }
-        catch (Exception ex)
-        {
-            throw new FacesException(
-                    "Could not retrieve value of component with path : "
-                            + getPathToComponent(component), ex);
-        }
+        Object value = ((ValueHolder) component).getValue();
         return value;
     }