Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3877

Add @ListenerFor(systemEventClass = PostRestoreStateEvent.class) causes StackOverflowException on MyFaces 2.2

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.2
    • 2.2.3
    • JSR-344
    • None

    Description

      From MyFaces users list Oleg Varaksin:

      Hello MyFaces team,

      We get a StackOverflowError since MyFaces 2.x. The stack trace is shown here http://forum.primefaces.org/viewtopic.php?f=14&t=36999

      The problem: Wenn we call super.processEvent(event) in the processEvent() of a custom component, we get a recursion which ends in StackOverflowError.

      @Override
      public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
      super.processEvent(event);
      ...
      }

      The call super.processEvent(event) is necessary because e.g. Mojarra executes there some important code. But if we look at processEvent() in the MyFaces' UIComponent, it iterates over all listeners for processEvent() and invokes them. That means, processEvent() of the custom component is invoked again. Does it work as designed or a is it a bug?

      It was working before MyFaces 2.x and it works for all Mojarra versions.

      Thanks in advance.

      The problem was caused by this line:

      @ListenerFor(systemEventClass = PostRestoreStateEvent.class)

      The line is not necessary, because all components are already subscribed to the event by default.

      The code we have in MyFaces is correct from spec perspective. See:

      https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1061

      But a simple check in this part can help to avoid the exception and keep running code that comes from 2.0/2.1. In fact, in 2.0/2.1 the offending line has no effect, but the problem was caused because MyFaces handles the case. It is recommended to remove the offending line from the users code anyway.

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            lu4242 Leonardo Uribe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: