Skip to content

Commit 66248a8

Browse files
committedFeb 17, 2015
WW-4427 adds complete fix
2 parents c5867e2 + e0d7239 commit 66248a8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed
 

‎xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,11 @@ public Object findValue(String expr, Class asType, boolean throwExceptionOnFailu
312312
setupExceptionOnFailure(throwExceptionOnFailure);
313313
return tryFindValueWhenExpressionIsNotNull(expr, asType);
314314
} catch (OgnlException e) {
315-
return handleOgnlException(expr, throwExceptionOnFailure, e);
315+
final Object value = handleOgnlException(expr, throwExceptionOnFailure, e);
316+
return converter.convertValue(getContext(), value, asType);
316317
} catch (Exception e) {
317-
return handleOtherException(expr, throwExceptionOnFailure, e);
318+
final Object value = handleOtherException(expr, throwExceptionOnFailure, e);
319+
return converter.convertValue(getContext(), value, asType);
318320
} finally {
319321
ReflectionContextState.clear(context);
320322
}

‎xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,25 @@ public void testArrayAsString() {
9494
}
9595

9696
public void testValuesFromContextAreConverted() {
97-
final OgnlValueStack vs = createValueStack();
97+
testValuesFromContextAreConverted("dogName");
98+
testValuesFromContextAreConverted("dog.name");
99+
}
98100

99-
final String propertyName = "dogName";
101+
private void testValuesFromContextAreConverted(String propertyName) {
102+
final OgnlValueStack vs = createValueStack();
100103
final String propertyValue = "Rover";
101104
vs.getContext().put(propertyName, new String[]{propertyValue});
102105

103106
assertEquals(propertyValue, vs.findValue(propertyName, String.class));
104107
}
105108

106109
public void testNullValueFromContextGetsConverted() {
107-
final OgnlValueStack vs = createValueStack();
110+
testNullValueFromContextGetsConverted("dogName");
111+
testNullValueFromContextGetsConverted("dog.name");
112+
}
108113

109-
final String propertyName = "dogName";
114+
private void testNullValueFromContextGetsConverted(String propertyName) {
115+
final OgnlValueStack vs = createValueStack();
110116
final String propertyValue = null;
111117
vs.getContext().put(propertyName, propertyValue);
112118

0 commit comments

Comments
 (0)