New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FullAjaxExceptionHandler can produce an endless loop #386

Closed
tnawrath opened this Issue Jun 6, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@tnawrath

tnawrath commented Jun 6, 2017

I am experiencing an endless loop in the FullAjaxExceptionHandler.
I am using Omnifaces 2.6 with Primefaces 6 on Wildfly 10.1.0 Final I instrumented the FullAjaxExceptionHandler as precise as i could as it is recommended in the Showcase

My web.xml contains this:

<error-page>
    <error-code>500</error-code>
    <location>/error/java/defaulterror.jsf</location>
</error-page>

Now lets say a user sends an Ajax Request like this:

<p:commandButton value="Do something long" 
    action="#{bean.doSomethingLong()}" async="true"/>

Bean:

public void doSomethingLong() {
    try {
        Thread.sleep(30000);
    } catch (InterruptedException e) {
    }
}

And now lets say the user does not wait for the Request to complete but instead hits the logout button:

    <p:commandButton value="Logout" 
        action="#{bean.invalidateSession()}" />

Bean:

public void invalidateSession() {
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.invalidateSession();
}

When the first request finally completes its waiting time, it produces an endless (or very long) loop which looks in the log like this:

at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.renderErrorPageView(FullAjaxExceptionHandler.java:541) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handleAjaxException(FullAjaxExceptionHandler.java:414) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handle(FullAjaxExceptionHandler.java:367) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.renderErrorPageView(FullAjaxExceptionHandler.java:541) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handleAjaxException(FullAjaxExceptionHandler.java:414) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handle(FullAjaxExceptionHandler.java:367) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.renderErrorPageView(FullAjaxExceptionHandler.java:541) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handleAjaxException(FullAjaxExceptionHandler.java:414) at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handle(FullAjaxExceptionHandler.java:367) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)

In other cases, like invalidating the session before calling the long request or invalidating the request inside of the long request, or any other exception in an ajax request, the exception page will be shown just fine. The content of the errorpage itself does not seem to matter. For completeness:

defaulterror.xhtml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>ErrorPage</title>
    </h:head>
    <h:body>
        This is bad.
    </h:body>
</html>

Omnifaces 2.4 and earlyer shows the internal 'Ooops!' error message, Omnifaces 2.5 until today produces an endless loop.

I also posted on Stackoverflow: https://stackoverflow.com/questions/44329126/omnifaces-fullajaxexceptionhandler-produces-endless-loop-config-issue-bug-or

@danilAREFY

This comment has been minimized.

Show comment
Hide comment
@danilAREFY

danilAREFY Jun 6, 2017

@tnawrath hi. I'm faced with a problem. As I understand it, the problem with undertow. You can try to Wildfly 11.0.0.Alpha1. There should not be this problem.

danilAREFY commented Jun 6, 2017

@tnawrath hi. I'm faced with a problem. As I understand it, the problem with undertow. You can try to Wildfly 11.0.0.Alpha1. There should not be this problem.

@tnawrath

This comment has been minimized.

Show comment
Hide comment
@tnawrath

tnawrath Jun 7, 2017

Well, I think the behavoir in 2.4 was better, because it showed an internal error instead of causing an endless loop. Would it be an option to change the Method renderErrorPageView in the class FullAjaxExceptionHandler back to how it was in 2.4?

tnawrath commented Jun 7, 2017

Well, I think the behavoir in 2.4 was better, because it showed an internal error instead of causing an endless loop. Would it be an option to change the Method renderErrorPageView in the class FullAjaxExceptionHandler back to how it was in 2.4?

BalusC added a commit that referenced this issue Jun 13, 2017

Fix #386: restore previous rendering logic as LifeCycle#render()
approach apparently goes into an infinite loop when error page handling
itself fails
@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Jun 13, 2017

Member

Can you confirm if today's 2.6.4-SNAPSHOT works for you?

Member

BalusC commented Jun 13, 2017

Can you confirm if today's 2.6.4-SNAPSHOT works for you?

@tnawrath

This comment has been minimized.

Show comment
Hide comment
@tnawrath

tnawrath Jun 13, 2017

Yes, I confirm that 2.6.4-SNAPSHOT on Wildfly 10.1. will now show the internal Error Page instead of an endless loop. Thank you.
At the moment, I can not work with Wildfly 11 to test the behavoir as suggested by @danilAREFY though.

tnawrath commented Jun 13, 2017

Yes, I confirm that 2.6.4-SNAPSHOT on Wildfly 10.1. will now show the internal Error Page instead of an endless loop. Thank you.
At the moment, I can not work with Wildfly 11 to test the behavoir as suggested by @danilAREFY though.

@tnawrath tnawrath closed this Jun 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment