Repository: struts Updated Branches: refs/heads/master 533b236fd -> 4b96958be
[WW-4737] preserve nulls instead of converting them to the string 'null' - Also simplify if-else logic to be more readable and avoid double-negatives Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/58667e64 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/58667e64 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/58667e64 Branch: refs/heads/master Commit: 58667e64970c528461cf7c5835f9a253c969f737 Parents: 47a415a Author: antuarc <carl.ant...@dsiti.qld.gov.au> Authored: Wed Feb 1 12:26:31 2017 +1000 Committer: antuarc <carl.ant...@dsiti.qld.gov.au> Committed: Wed Feb 1 12:26:31 2017 +1000 ---------------------------------------------------------------------- .../org/apache/struts2/dispatcher/Parameter.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/58667e64/core/src/main/java/org/apache/struts2/dispatcher/Parameter.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Parameter.java b/core/src/main/java/org/apache/struts2/dispatcher/Parameter.java index 30781a1..4e06ef6 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Parameter.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Parameter.java @@ -1,5 +1,7 @@ package org.apache.struts2.dispatcher; +import java.util.Objects; + import org.apache.commons.lang3.StringEscapeUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -42,23 +44,23 @@ public interface Parameter { } private String[] toStringArray() { - if (value != null && value.getClass().isArray()) { + if (value == null) { + LOG.trace("The value is null, empty array of string will be returned!"); + return new String[]{}; + } else if (value.getClass().isArray()) { LOG.trace("Converting value {} to array of strings", value); Object[] values = (Object[]) value; String[] strValues = new String[values.length]; int i = 0; for (Object v : values) { - strValues[i] = String.valueOf(v); + strValues[i] = Objects.toString(v, null); i++; } return strValues; - } else if (value != null) { - LOG.trace("Converting value {} to simple string", value); - return new String[]{ String.valueOf(value) }; } else { - LOG.trace("The value is null, empty array of string will be returned!"); - return new String[]{}; + LOG.trace("Converting value {} to simple string", value); + return new String[]{ value.toString() }; } }