diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java index 8285b7b14..3e622d5d9 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlUtil.java @@ -266,18 +266,22 @@ public class OgnlUtil { tree = expressions.get(expression); if (tree == null) { tree = Ognl.parseExpression(expression); + checkEnableEvalExpression(tree, context); expressions.putIfAbsent(expression, tree); } } else { tree = Ognl.parseExpression(expression); - } - - if (!enableEvalExpression && isEvalExpression(tree, context)) { - throw new OgnlException("Eval expressions has been disabled"); + checkEnableEvalExpression(tree, context); } return tree; } + + private void checkEnableEvalExpression(Object tree, Map context) throws OgnlException { + if (!enableEvalExpression && isEvalExpression(tree, context)) { + throw new OgnlException("Eval expressions has been disabled!"); + } + } /** * Copies the properties in the object "from" and sets them in the object "to"