Skip to content
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

isErrorPage() check in RestoreViewPhase fails when thrown exception has a null message #5529

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions impl/src/main/java/com/sun/faces/lifecycle/RestoreViewPhase.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
import java.util.Set;
import java.util.logging.Logger;

import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.util.Util;

import jakarta.el.MethodExpression;
import jakarta.faces.FacesException;
import jakarta.faces.application.ProtectedViewException;
Expand All @@ -70,6 +66,10 @@
import jakarta.faces.view.ViewDeclarationLanguage;
import jakarta.faces.view.ViewMetadata;

import com.sun.faces.util.FacesLogger;
import com.sun.faces.util.MessageUtils;
import com.sun.faces.util.Util;

/**
* <B>Lifetime And Scope</B>
* <P>
Expand All @@ -78,7 +78,9 @@
*/
public class RestoreViewPhase extends Phase {

private static final String WEBAPP_ERROR_PAGE_MARKER = "jakarta.servlet.error.message";
private static final String WEBAPP_ERROR_MESSAGE_MARKER = "jakarta.servlet.error.message"; // RequestDispatcher.ERROR_MESSAGE
private static final String WEBAPP_ERROR_EXCEPTION_MARKER = "jakarta.servlet.error.exception"; // RequestDispatcher.ERROR_EXCEPTION

private static final Logger LOGGER = FacesLogger.LIFECYCLE.getLogger();

private static final Set<VisitHint> SKIP_ITERATION_HINT = EnumSet.of(SKIP_ITERATION);
Expand Down Expand Up @@ -430,11 +432,12 @@ private void notifyAfter(FacesContext context, Lifecycle lifecycle) {
* Use this method to determine if the current request is an error page to avoid the above condition.
*
* @param context the FacesContext for the current request
* @return <code>true</code> if <code>WEBAPP_ERROR_PAGE_MARKER</code> is found in the request, otherwise return
* <code>false</code>
* @return <code>true</code> if <code>WEBAPP_ERROR_MESSAGE_MARKER</code> or <code>WEBAPP_ERROR_EXCEPTION_MARKER</code>
* is found in the request, otherwise return <code>false</code>
*/
private static boolean isErrorPage(FacesContext context) {
return context.getExternalContext().getRequestMap().get(WEBAPP_ERROR_PAGE_MARKER) != null;
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
return requestMap.get(WEBAPP_ERROR_MESSAGE_MARKER) != null || requestMap.get(WEBAPP_ERROR_EXCEPTION_MARKER) != null;
}

}
Loading