diff --git a/src/main/java/org/apache/ibatis/scripting/xmltags/ExpressionEvaluator.java b/src/main/java/org/apache/ibatis/scripting/xmltags/ExpressionEvaluator.java index 1559a3cc00b..bca2d71dfd3 100644 --- a/src/main/java/org/apache/ibatis/scripting/xmltags/ExpressionEvaluator.java +++ b/src/main/java/org/apache/ibatis/scripting/xmltags/ExpressionEvaluator.java @@ -28,6 +28,8 @@ */ public class ExpressionEvaluator { + public static final ExpressionEvaluator INSTANCE = new ExpressionEvaluator(); + public boolean evaluateBoolean(String expression, Object parameterObject) { Object value = OgnlCache.getValue(expression, parameterObject); if (value instanceof Boolean) { diff --git a/src/main/java/org/apache/ibatis/scripting/xmltags/ForEachSqlNode.java b/src/main/java/org/apache/ibatis/scripting/xmltags/ForEachSqlNode.java index 30dfb631c9f..08d46419813 100644 --- a/src/main/java/org/apache/ibatis/scripting/xmltags/ForEachSqlNode.java +++ b/src/main/java/org/apache/ibatis/scripting/xmltags/ForEachSqlNode.java @@ -27,7 +27,7 @@ public class ForEachSqlNode implements SqlNode { public static final String ITEM_PREFIX = "__frch_"; - private final ExpressionEvaluator evaluator; + private final ExpressionEvaluator evaluator = ExpressionEvaluator.INSTANCE; private final String collectionExpression; private final Boolean nullable; private final SqlNode contents; @@ -53,7 +53,6 @@ public ForEachSqlNode(Configuration configuration, SqlNode contents, String coll */ public ForEachSqlNode(Configuration configuration, SqlNode contents, String collectionExpression, Boolean nullable, String index, String item, String open, String close, String separator) { - this.evaluator = new ExpressionEvaluator(); this.collectionExpression = collectionExpression; this.nullable = nullable; this.contents = contents; diff --git a/src/main/java/org/apache/ibatis/scripting/xmltags/IfSqlNode.java b/src/main/java/org/apache/ibatis/scripting/xmltags/IfSqlNode.java index eae33cec1da..bb15cc8a84b 100644 --- a/src/main/java/org/apache/ibatis/scripting/xmltags/IfSqlNode.java +++ b/src/main/java/org/apache/ibatis/scripting/xmltags/IfSqlNode.java @@ -19,14 +19,13 @@ * @author Clinton Begin */ public class IfSqlNode implements SqlNode { - private final ExpressionEvaluator evaluator; + private final ExpressionEvaluator evaluator = ExpressionEvaluator.INSTANCE; private final String test; private final SqlNode contents; public IfSqlNode(SqlNode contents, String test) { this.test = test; this.contents = contents; - this.evaluator = new ExpressionEvaluator(); } @Override