From 9ed7fce11aca24c1f951a49cec9599ba5de7bd91 Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Sat, 20 Jan 2007 08:21:22 +0000 Subject: [PATCH] Fixed NPE when action mapper for current request is null WW-1662 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@498087 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/struts2/dispatcher/ServletRedirectResult.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java index abed1aa00..cb8501ce9 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java @@ -27,6 +27,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.mapper.ActionMapper; +import org.apache.struts2.dispatcher.mapper.ActionMapping; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; @@ -123,8 +124,12 @@ public class ServletRedirectResult extends StrutsResultSupport { if (isPathUrl(finalLocation)) { if (!finalLocation.startsWith("/")) { - String namespace = actionMapper.getMapping( - request, Dispatcher.getInstance().getConfigurationManager()).getNamespace(); + ActionMapping mapping = actionMapper.getMapping( + request, Dispatcher.getInstance().getConfigurationManager()); + String namespace = null; + if (mapping != null) { + namespace = mapping.getNamespace(); + } if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) { finalLocation = namespace + "/" + finalLocation;