From 4dcdd9a224fb75bcad6db578b283f6268b500558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Mon, 12 Aug 2024 15:20:37 +0200 Subject: [PATCH] Polishing See gh-21590 --- .../interceptor/AbstractCacheInvoker.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheInvoker.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheInvoker.java index a96fca24c0..84e36757d6 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheInvoker.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheInvoker.java @@ -30,6 +30,7 @@ import org.springframework.util.function.SingletonSupplier; * * @author Stephane Nicoll * @author Juergen Hoeller + * @author Simon Baslé * @since 4.1 * @see org.springframework.cache.interceptor.CacheErrorHandler */ @@ -82,6 +83,14 @@ public abstract class AbstractCacheInvoker { } } + /** + * Execute {@link Cache#get(Object, Callable)} on the specified + * {@link Cache} and invoke the error handler if an exception occurs. + * Invokes the {@code valueLoader} if the handler does not throw any + * exception, which simulates a cache read-through in case of error. + * @since 6.2 + * @see Cache#get(Object, Callable) + */ @Nullable protected T doGet(Cache cache, Object key, Callable valueLoader) { try { @@ -101,6 +110,15 @@ public abstract class AbstractCacheInvoker { } } + + /** + * Execute {@link Cache#retrieve(Object)} on the specified {@link Cache} + * and invoke the error handler if an exception occurs. + * Returns {@code null} if the handler does not throw any exception, which + * simulates a cache miss in case of error. + * @since 6.2 + * @see Cache#retrieve(Object) + */ @Nullable protected CompletableFuture doRetrieve(Cache cache, Object key) { try { @@ -115,6 +133,15 @@ public abstract class AbstractCacheInvoker { } } + + /** + * Execute {@link Cache#retrieve(Object, Supplier)} on the specified + * {@link Cache} and invoke the error handler if an exception occurs. + * Invokes the {@code valueLoader} if the handler does not throw any + * exception, which simulates a cache read-through in case of error. + * @since 6.2 + * @see Cache#retrieve(Object, Supplier) + */ protected CompletableFuture doRetrieve(Cache cache, Object key, Supplier> valueLoader) { try { return cache.retrieve(key, valueLoader);