From f4a73b79b844486da5d39f4c0b7b997c72eb56ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Mon, 12 Aug 2024 14:54:15 +0200 Subject: [PATCH] Avoid CacheAspectSupport#findInCaches fall through to reactive handler Prior to this commit if the return type is a CompletableFuture but a cache get returns null, the execution falls through to the reactiveCachingHandler. This commit ensures that evaluation instead continues onto the next cache (if any). Closes gh-33371 --- .../springframework/cache/interceptor/CacheAspectSupport.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index bf391471f15..568aea4780b 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -510,6 +510,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker (value != null ? CompletableFuture.completedFuture(unwrapCacheValue(value)) : null), invoker, method, contexts)); } + else { + continue; + } } if (this.reactiveCachingHandler != null) { Object returnValue = this.reactiveCachingHandler.findInCaches(