Leonardo Uribe created MYFACES-3877:
---------------------------------------
Summary: Add @ListenerFor(systemEventClass =
PostRestoreStateEvent.class) causes StackOverflowException on MyFaces 2.2
Key: MYFACES-3877
URL: https://issues.apache.org/jira/browse/MYFACES-3877
Project: MyFaces Core
Issue Type: Bug
Components: JSR-344
Affects Versions: 2.2.2
Reporter: Leonardo Uribe
Assignee: Leonardo Uribe
>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.
--
This message was sent by Atlassian JIRA
(v6.2#6252)