3232import org .springframework .core .convert .TypeDescriptor ;
3333import org .springframework .data .mapping .PropertyPath ;
3434import org .springframework .data .mapping .PropertyReferenceException ;
35+ import org .springframework .expression .EvaluationContext ;
3536import org .springframework .expression .Expression ;
3637import org .springframework .expression .ExpressionException ;
3738import org .springframework .expression .spel .SpelEvaluationException ;
3839import org .springframework .expression .spel .standard .SpelExpressionParser ;
40+ import org .springframework .expression .spel .support .SimpleEvaluationContext ;
3941import org .springframework .util .Assert ;
4042import org .springframework .util .ConcurrentReferenceHashMap ;
4143
@@ -209,6 +211,7 @@ static class TypedSpelPath extends SpelPath {
209211
210212 private static final String INVALID_PATH_REFERENCE = "Invalid path reference %s on type %s (from source %s)!" ;
211213 private static final Map <CacheKey , TypedSpelPath > TYPED_PATHS = new ConcurrentReferenceHashMap <>(32 );
214+ private static final EvaluationContext CONTEXT = SimpleEvaluationContext .forReadWriteDataBinding ().build ();
212215
213216 private final Class <?> type ;
214217
@@ -254,7 +257,7 @@ public <T> T getValue(Object target) {
254257 Assert .notNull (target , "Target must not be null!" );
255258
256259 try {
257- return (T ) expression .getValue (target );
260+ return (T ) expression .getValue (CONTEXT , target );
258261 } catch (ExpressionException o_O ) {
259262 throw new PatchException ("Unable to get value from target" , o_O );
260263 }
@@ -270,7 +273,7 @@ public void setValue(Object target, Object value) {
270273
271274 Assert .notNull (target , "Target must not be null!" );
272275
273- expression .setValue (target , value );
276+ expression .setValue (CONTEXT , target , value );
274277 }
275278
276279 /**
@@ -283,7 +286,7 @@ public Class<?> getType(Object root) {
283286
284287 Assert .notNull (root , "Root object must not be null!" );
285288
286- return expression .getValueType (root );
289+ return expression .getValueType (CONTEXT , root );
287290 }
288291
289292 /**
@@ -390,7 +393,7 @@ private TypedSpelPath getParent() {
390393 }
391394
392395 private TypeDescriptor getTypeDescriptor (Object target ) {
393- return expression .getValueTypeDescriptor (target );
396+ return expression .getValueTypeDescriptor (CONTEXT , target );
394397 }
395398
396399 private Integer getTargetListIndex () {
0 commit comments