Skip to content

Commit 6b3092c

Browse files
committed
Clear expression caches on context shutdown
Issue: SPR-12691
1 parent 37c04bd commit 6b3092c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ protected <T> T getBean(String beanName, Class<T> expectedType) {
288288
*/
289289
protected void clearMetadataCache() {
290290
this.metadataCache.clear();
291+
this.evaluator.clear();
291292
}
292293

293294
protected Object execute(CacheOperationInvoker invoker, Object target, Method method, Object[] args) {

spring-context/src/main/java/org/springframework/cache/interceptor/ExpressionEvaluator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ public boolean unless(String unlessExpression, AnnotatedElementKey methodKey, Ev
123123
return getExpression(this.unlessCache, methodKey, unlessExpression).getValue(evalContext, boolean.class);
124124
}
125125

126+
/**
127+
* Clear all caches.
128+
*/
129+
void clear() {
130+
this.keyCache.clear();
131+
this.conditionCache.clear();
132+
this.unlessCache.clear();
133+
this.targetMethodCache.clear();
134+
}
135+
126136
private Method getTargetMethod(Class<?> targetClass, Method method) {
127137
AnnotatedElementKey methodKey = new AnnotatedElementKey(method, targetClass);
128138
Method targetMethod = this.targetMethodCache.get(methodKey);

0 commit comments

Comments
 (0)