null check bug
This commit is contained in:
@@ -57,12 +57,12 @@ public class ActionResultExposer implements Serializable {
|
||||
public ActionResultExposer(Expression resultExpression, Class expectedResultType,
|
||||
ConversionService conversionService) {
|
||||
Assert.notNull(resultExpression, "The result expression is required");
|
||||
if (expectedResultType != null) {
|
||||
Assert.notNull(conversionService, "A conversionService is required with an expectedResultType");
|
||||
}
|
||||
this.resultExpression = resultExpression;
|
||||
this.expectedResultType = expectedResultType;
|
||||
if (this.expectedResultType != null) {
|
||||
Assert.notNull(conversionService, "A conversionService is required with an expectedResultType");
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,10 +93,11 @@ public class ActionResultExposer implements Serializable {
|
||||
* @param value the raw value to be converted
|
||||
*/
|
||||
private Object applyTypeConversion(Object value) {
|
||||
if (expectedResultType == null) {
|
||||
if (value == null || expectedResultType == null) {
|
||||
return value;
|
||||
} else {
|
||||
return conversionService.getConversionExecutor(value.getClass(), expectedResultType).execute(value);
|
||||
}
|
||||
return conversionService.getConversionExecutor(value.getClass(), expectedResultType).execute(value);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.webflow.test.MockRequestContext;
|
||||
|
||||
public class ActionResultExposerTests extends TestCase {
|
||||
|
||||
public void testEvaluateExpressionNullResult() throws Exception {
|
||||
public void testEvaluateExpressionResult() throws Exception {
|
||||
StaticExpression resultExpression = new StaticExpression("");
|
||||
ActionResultExposer exposer = new ActionResultExposer(resultExpression, null, null);
|
||||
MockRequestContext context = new MockRequestContext();
|
||||
@@ -16,6 +16,14 @@ public class ActionResultExposerTests extends TestCase {
|
||||
assertEquals("foo", resultExpression.getValue(null));
|
||||
}
|
||||
|
||||
public void testEvaluateExpressionNullResult() throws Exception {
|
||||
StaticExpression resultExpression = new StaticExpression("");
|
||||
ActionResultExposer exposer = new ActionResultExposer(resultExpression, null, null);
|
||||
MockRequestContext context = new MockRequestContext();
|
||||
exposer.exposeResult(null, context);
|
||||
assertEquals(null, resultExpression.getValue(null));
|
||||
}
|
||||
|
||||
public void testEvaluateExpressionResultExposerWithTypeConversion() throws Exception {
|
||||
StaticExpression resultExpression = new StaticExpression("");
|
||||
ActionResultExposer exposer = new ActionResultExposer(resultExpression, Integer.class,
|
||||
|
||||
Reference in New Issue
Block a user