WW-4427 - Converters are no longer applied to values coming from the context on error path
Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e0d72397 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e0d72397 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e0d72397 Branch: refs/heads/master Commit: e0d72397c24542a8b83a371a36590570ccd8fd74 Parents: 76ea79f Author: Przemek Bruski <pbru...@atlassian.com> Authored: Sun Feb 15 10:40:13 2015 +0100 Committer: Przemek Bruski <pbru...@atlassian.com> Committed: Sun Feb 15 10:40:13 2015 +0100 ---------------------------------------------------------------------- .../com/opensymphony/xwork2/ognl/OgnlValueStack.java | 6 ++++-- .../opensymphony/xwork2/ognl/OgnlValueStackTest.java | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/e0d72397/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java index 7fa70f7..1b09ef6 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java @@ -312,9 +312,11 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS setupExceptionOnFailure(throwExceptionOnFailure); return tryFindValueWhenExpressionIsNotNull(expr, asType); } catch (OgnlException e) { - return handleOgnlException(expr, throwExceptionOnFailure, e); + final Object value = handleOgnlException(expr, throwExceptionOnFailure, e); + return converter.convertValue(getContext(), value, asType); } catch (Exception e) { - return handleOtherException(expr, throwExceptionOnFailure, e); + final Object value = handleOtherException(expr, throwExceptionOnFailure, e); + return converter.convertValue(getContext(), value, asType); } finally { ReflectionContextState.clear(context); } http://git-wip-us.apache.org/repos/asf/struts/blob/e0d72397/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java index 8c7c3ae..612435d 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java @@ -94,9 +94,12 @@ public class OgnlValueStackTest extends XWorkTestCase { } public void testValuesFromContextAreConverted() { - final OgnlValueStack vs = createValueStack(); + testValuesFromContextAreConverted("dogName"); + testValuesFromContextAreConverted("dog.name"); + } - final String propertyName = "dogName"; + private void testValuesFromContextAreConverted(String propertyName) { + final OgnlValueStack vs = createValueStack(); final String propertyValue = "Rover"; vs.getContext().put(propertyName, new String[]{propertyValue}); @@ -104,9 +107,12 @@ public class OgnlValueStackTest extends XWorkTestCase { } public void testNullValueFromContextGetsConverted() { - final OgnlValueStack vs = createValueStack(); + testNullValueFromContextGetsConverted("dogName"); + testNullValueFromContextGetsConverted("dog.name"); + } - final String propertyName = "dogName"; + private void testNullValueFromContextGetsConverted(String propertyName) { + final OgnlValueStack vs = createValueStack(); final String propertyValue = null; vs.getContext().put(propertyName, propertyValue);