Skip to content

Commit 47d3819

Browse files
committed
Merge pull request #27604 from Xjzon
* pr/27604: Polish "Add support for custom expression parsing" Add support for custom expression parsing Closes gh-27604
2 parents 0416168 + f295c8b commit 47d3819

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected ParameterNameDiscoverer getParameterNameDiscoverer() {
7575

7676
/**
7777
* Return the {@link Expression} for the specified SpEL value
78-
* <p>Parse the expression if it hasn't been already.
78+
* <p>{@link #parseExpression(String) Parse the expression} if it hasn't been already.
7979
* @param cache the cache to use
8080
* @param elementKey the element on which the expression is defined
8181
* @param expression the expression to parse
@@ -86,12 +86,21 @@ protected Expression getExpression(Map<ExpressionKey, Expression> cache,
8686
ExpressionKey expressionKey = createKey(elementKey, expression);
8787
Expression expr = cache.get(expressionKey);
8888
if (expr == null) {
89-
expr = getParser().parseExpression(expression);
89+
expr = parseExpression(expression);
9090
cache.put(expressionKey, expr);
9191
}
9292
return expr;
9393
}
9494

95+
/**
96+
* Parse the specified {@code expression}.
97+
* @param expression the expression to parse
98+
* @since 5.3.13
99+
*/
100+
protected Expression parseExpression(String expression) {
101+
return getParser().parseExpression(expression);
102+
}
103+
95104
private ExpressionKey createKey(AnnotatedElementKey elementKey, String expression) {
96105
return new ExpressionKey(elementKey, expression);
97106
}

spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)