Skip to content

Commit

Permalink
Fix #5528: isErrorPage() check in RestoreViewPhase fails when thrown
Browse files Browse the repository at this point in the history
exception has a null message
  • Loading branch information
BalusC committed Nov 16, 2024
1 parent 5852612 commit c4a0c6b
Showing 1 changed file with 11 additions and 8 deletions.
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;
}

}

0 comments on commit c4a0c6b

Please sign in to comment.