@@ -118,10 +118,8 @@ public String getExpressionString() {
118118 public Object getValue () throws EvaluationException {
119119 if (this .compiledAst != null ) {
120120 try {
121- TypedValue contextRoot =
122- (this .evaluationContext != null ? this .evaluationContext .getRootObject () : null );
123- return this .compiledAst .getValue (
124- (contextRoot != null ? contextRoot .getValue () : null ), this .evaluationContext );
121+ EvaluationContext context = getEvaluationContext ();
122+ return this .compiledAst .getValue (context .getRootObject ().getValue (), context );
125123 }
126124 catch (Throwable ex ) {
127125 // If running in mixed mode, revert to interpreted
@@ -148,10 +146,8 @@ public Object getValue() throws EvaluationException {
148146 public <T > T getValue (@ Nullable Class <T > expectedResultType ) throws EvaluationException {
149147 if (this .compiledAst != null ) {
150148 try {
151- TypedValue contextRoot =
152- (this .evaluationContext != null ? this .evaluationContext .getRootObject () : null );
153- Object result = this .compiledAst .getValue (
154- (contextRoot != null ? contextRoot .getValue () : null ), this .evaluationContext );
149+ EvaluationContext context = getEvaluationContext ();
150+ Object result = this .compiledAst .getValue (context .getRootObject ().getValue (), context );
155151 if (expectedResultType == null ) {
156152 return (T ) result ;
157153 }
@@ -185,7 +181,7 @@ public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationEx
185181 public Object getValue (Object rootObject ) throws EvaluationException {
186182 if (this .compiledAst != null ) {
187183 try {
188- return this .compiledAst .getValue (rootObject , this . evaluationContext );
184+ return this .compiledAst .getValue (rootObject , getEvaluationContext () );
189185 }
190186 catch (Throwable ex ) {
191187 // If running in mixed mode, revert to interpreted
@@ -213,7 +209,7 @@ public Object getValue(Object rootObject) throws EvaluationException {
213209 public <T > T getValue (Object rootObject , @ Nullable Class <T > expectedResultType ) throws EvaluationException {
214210 if (this .compiledAst != null ) {
215211 try {
216- Object result = this .compiledAst .getValue (rootObject , null );
212+ Object result = this .compiledAst .getValue (rootObject , getEvaluationContext () );
217213 if (expectedResultType == null ) {
218214 return (T )result ;
219215 }
@@ -250,8 +246,7 @@ public Object getValue(EvaluationContext context) throws EvaluationException {
250246
251247 if (this .compiledAst != null ) {
252248 try {
253- TypedValue contextRoot = context .getRootObject ();
254- return this .compiledAst .getValue (contextRoot .getValue (), context );
249+ return this .compiledAst .getValue (context .getRootObject ().getValue (), context );
255250 }
256251 catch (Throwable ex ) {
257252 // If running in mixed mode, revert to interpreted
@@ -280,8 +275,7 @@ public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResu
280275
281276 if (this .compiledAst != null ) {
282277 try {
283- TypedValue contextRoot = context .getRootObject ();
284- Object result = this .compiledAst .getValue (contextRoot .getValue (), context );
278+ Object result = this .compiledAst .getValue (context .getRootObject ().getValue (), context );
285279 if (expectedResultType != null ) {
286280 return ExpressionUtils .convertTypedValue (context , new TypedValue (result ), expectedResultType );
287281 }
@@ -315,7 +309,7 @@ public Object getValue(EvaluationContext context, Object rootObject) throws Eval
315309
316310 if (this .compiledAst != null ) {
317311 try {
318- return this .compiledAst .getValue (rootObject ,context );
312+ return this .compiledAst .getValue (rootObject , context );
319313 }
320314 catch (Throwable ex ) {
321315 // If running in mixed mode, revert to interpreted
0 commit comments