Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-545

DeltaSpikeExceptionHandler getRootCause assumes caught FacesException is wrapping another Exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.6
    • 0.7
    • JSF-Module
    • None
    • Myfaces 2.2.1 Tomcat 7.x Deltaspike 0.6

    Description

      It may be incorrect by the underlying JSF implementation to not wrap another exception with FacesException. However errors such as detection of duplicate id's are in nature FacesExceptions and the opposite could be argued.

      Regardless it's best if DeltaspikeExceptionHandler null checks rather then assuming every FacesException wraps another Exception to ensure robustness.

      This is the code Thomas Andraschko proposed as a fix. I have verified it locally and it fixed my problem.

      In DeltaspikeExceptionHandler, override getRootCause:
      @Override
      public Throwable getRootCause(Throwable throwable)
      {
      while ((ELException.class.isInstance(throwable) || FacesException.class.isInstance(throwable))
      && throwable.getCause() != null)

      { throwable = throwable.getCause(); }

      return throwable;
      }

      Before local fix:
      java.lang.IllegalArgumentException: exception must not be null
      org.apache.deltaspike.core.api.exception.control.event.ExceptionStackEvent.<init>(ExceptionStackEvent.java:60)
      org.apache.deltaspike.core.impl.exception.control.ExceptionHandlerBroadcaster.executeHandlers(ExceptionHandlerBroadcaster.java:75)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces

      After:
      javax.faces.FacesException: Component with id:info not found
      org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.getComponentId(HtmlAjaxBehaviorRenderer.java:461)
      org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.build(HtmlAjaxBehaviorRenderer.java:433)
      org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.mapToString(HtmlAjaxBehaviorRenderer.java:405)
      org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.makeAjax(HtmlAjaxBehaviorRenderer.java:158)
      org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer.getScript(HtmlAjaxBehaviorRenderer.java:102)

      Attachments

        Issue Links

          Activity

            People

              tandraschko Thomas Andraschko
              karlkilden Karl Kildén
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: