Browse Source

Merge pull request #26028 from hzmpay

* pr/26028:
  Update copyright header of changed file
  Use computeIfAbsent in SpelCompiler and AdvisedSupport

Closes gh-26028
pull/31115/head
Stephane Nicoll 2 years ago
parent
commit
22fd6df711
  1. 10
      spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
  2. 8
      spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java

10
spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java

@ -479,14 +479,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised { @@ -479,14 +479,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* @return a List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
*/
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(Method method, @Nullable Class<?> targetClass) {
MethodCacheKey cacheKey = new MethodCacheKey(method);
List<Object> cached = this.methodCache.get(cacheKey);
if (cached == null) {
cached = this.advisorChainFactory.getInterceptorsAndDynamicInterceptionAdvice(
this, method, targetClass);
this.methodCache.put(cacheKey, cached);
}
return cached;
return this.methodCache.computeIfAbsent(new MethodCacheKey(method), k ->
this.advisorChainFactory.getInterceptorsAndDynamicInterceptionAdvice(this, method, targetClass));
}
/**

8
spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -233,11 +233,7 @@ public final class SpelCompiler implements Opcodes { @@ -233,11 +233,7 @@ public final class SpelCompiler implements Opcodes {
if (compiler == null) {
// Full lock now since we're creating a child ClassLoader
synchronized (compilers) {
compiler = compilers.get(clToUse);
if (compiler == null) {
compiler = new SpelCompiler(clToUse);
compilers.put(clToUse, compiler);
}
return compilers.computeIfAbsent(clToUse, SpelCompiler::new);
}
}
return compiler;

Loading…
Cancel
Save