From 6862e2a5c52a7254e6374da07bb2b72a86b51dc1 Mon Sep 17 00:00:00 2001 From: Wesley Wannemacher Date: Tue, 2 Jun 2009 17:26:17 +0000 Subject: [PATCH] WW-3107, fixing NPE, good catch Andrey Vasenin git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@781086 13f79535-47bb-0310-9956-ffa450edef68 --- .../dispatcher/ServletRedirectResult.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 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 1fc4a427b..b509cf1b8 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java @@ -167,17 +167,19 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec } ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode()); - Map resultConfigParams = resultConfig.getParams(); - for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) { - Map.Entry e = (Map.Entry) i.next(); + if (resultConfig != null ) { + Map resultConfigParams = resultConfig.getParams(); + for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) { + Map.Entry e = (Map.Entry) i.next(); - if (!getProhibitedResultParams().contains(e.getKey())) { - requestParameters.put(e.getKey().toString(), - e.getValue() == null ? "" : - conditionalParse(e.getValue().toString(), invocation)); - String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue().toString(), invocation); - if (!supressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) { - requestParameters.put(e.getKey().toString(), potentialValue); + if (!getProhibitedResultParams().contains(e.getKey())) { + requestParameters.put(e.getKey().toString(), + e.getValue() == null ? "" : + conditionalParse(e.getValue().toString(), invocation)); + String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue().toString(), invocation); + if (!supressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) { + requestParameters.put(e.getKey().toString(), potentialValue); + } } } } @@ -232,7 +234,7 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec /** * Sets the supressEmptyParameters option * - * @param suppress The new value for this option + * @param supressEmptyParameters The new value for this option */ public void setSupressEmptyParameters(boolean supressEmptyParameters) { this.supressEmptyParameters = supressEmptyParameters;