DATAKV-212 - Favor SimpleEvaluationContext over StandardEvaluationContext
This allows us to restrict data binding to be read only.
This commit is contained in:
@@ -37,7 +37,7 @@ import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.ParametersParameterAccessor;
|
||||
import org.springframework.data.repository.query.QueryMethod;
|
||||
import org.springframework.data.repository.query.parser.PartTree;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.SimpleEvaluationContext;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SpelQueryEngine}.
|
||||
@@ -99,7 +99,8 @@ public class SpelQueryEngineUnitTests {
|
||||
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(
|
||||
new QueryMethod(method, metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args));
|
||||
|
||||
return new SpelCriteria(creator.createQuery().getCriteria(), new StandardEvaluationContext(args));
|
||||
return new SpelCriteria(creator.createQuery().getCriteria(),
|
||||
SimpleEvaluationContext.forReadOnlyDataBinding().withInstanceMethods().withRootObject(args).build());
|
||||
}
|
||||
|
||||
interface PersonRepository {
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.data.repository.query.ParametersParameterAccessor;
|
||||
import org.springframework.data.repository.query.QueryMethod;
|
||||
import org.springframework.data.repository.query.parser.PartTree;
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.SimpleEvaluationContext;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -339,7 +339,8 @@ public class SpelQueryCreatorUnitTests {
|
||||
new QueryMethod(method, metadataMock, new SpelAwareProxyProjectionFactory()).getParameters(), args));
|
||||
|
||||
KeyValueQuery<SpelExpression> q = creator.createQuery();
|
||||
q.getCriteria().setEvaluationContext(new StandardEvaluationContext(args));
|
||||
q.getCriteria().setEvaluationContext(
|
||||
SimpleEvaluationContext.forReadOnlyDataBinding().withRootObject(args).withInstanceMethods().build());
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user