@@ -488,20 +488,27 @@ public int countAdvicesOfType(@Nullable Class<?> adviceClass) {
488
488
* @return a List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
489
489
*/
490
490
public List <Object > getInterceptorsAndDynamicInterceptionAdvice (Method method , @ Nullable Class <?> targetClass ) {
491
- if (this .methodCache == null ) {
491
+ List <Object > cachedInterceptors ;
492
+ if (this .methodCache != null ) {
493
+ // Method-specific cache for method-specific pointcuts
494
+ MethodCacheKey cacheKey = new MethodCacheKey (method );
495
+ cachedInterceptors = this .methodCache .get (cacheKey );
496
+ if (cachedInterceptors == null ) {
497
+ cachedInterceptors = this .advisorChainFactory .getInterceptorsAndDynamicInterceptionAdvice (
498
+ this , method , targetClass );
499
+ this .methodCache .put (cacheKey , cachedInterceptors );
500
+ }
501
+ }
502
+ else {
492
503
// Shared cache since there are no method-specific advisors (see below).
493
- List < Object > cachedInterceptors = this .cachedInterceptors ;
504
+ cachedInterceptors = this .cachedInterceptors ;
494
505
if (cachedInterceptors == null ) {
495
506
cachedInterceptors = this .advisorChainFactory .getInterceptorsAndDynamicInterceptionAdvice (
496
507
this , method , targetClass );
497
508
this .cachedInterceptors = cachedInterceptors ;
498
509
}
499
- return cachedInterceptors ;
500
510
}
501
-
502
- // Method-specific cache for method-specific pointcuts
503
- return this .methodCache .computeIfAbsent (new MethodCacheKey (method ), k ->
504
- this .advisorChainFactory .getInterceptorsAndDynamicInterceptionAdvice (this , method , targetClass ));
511
+ return cachedInterceptors ;
505
512
}
506
513
507
514
/**
0 commit comments