Class LoggingCacheErrorHandler
java.lang.Object
org.springframework.cache.interceptor.LoggingCacheErrorHandler
- All Implemented Interfaces:
CacheErrorHandler
A
CacheErrorHandler
implementation that logs error message. Can be
used when underlying cache errors should be ignored.- Since:
- 5.3.16
- Author:
- Adam Ostrožlík, Stephane Nicoll
-
Constructor Summary
ConstructorDescriptionCreate an instance that does not log stack traces.LoggingCacheErrorHandler
(Log logger, boolean logStacktrace) Create an instance with thelogger
to use. -
Method Summary
Modifier and TypeMethodDescriptionvoid
handleCacheClearError
(RuntimeException exception, Cache cache) Handle the given runtime exception thrown by the cache provider when clearing the specifiedCache
, possibly rethrowing it as a fatal exception.void
handleCacheEvictError
(RuntimeException exception, Cache cache, Object key) Handle the given runtime exception thrown by the cache provider when clearing an item with the specifiedkey
, possibly rethrowing it as a fatal exception.void
handleCacheGetError
(RuntimeException exception, Cache cache, Object key) Handle the given runtime exception thrown by the cache provider when retrieving an item with the specifiedkey
, possibly rethrowing it as a fatal exception.void
handleCachePutError
(RuntimeException exception, Cache cache, Object key, Object value) Handle the given runtime exception thrown by the cache provider when updating an item with the specifiedkey
andvalue
, possibly rethrowing it as a fatal exception.protected void
logCacheError
(Log logger, String message, RuntimeException ex) Log the specified message.
-
Constructor Details
-
LoggingCacheErrorHandler
Create an instance with thelogger
to use.- Parameters:
logger
- the logger to uselogStacktrace
- whether to log stack trace
-
LoggingCacheErrorHandler
public LoggingCacheErrorHandler()Create an instance that does not log stack traces.
-
-
Method Details
-
handleCacheGetError
Description copied from interface:CacheErrorHandler
Handle the given runtime exception thrown by the cache provider when retrieving an item with the specifiedkey
, possibly rethrowing it as a fatal exception.- Specified by:
handleCacheGetError
in interfaceCacheErrorHandler
- Parameters:
exception
- the exception thrown by the cache providercache
- the cachekey
- the key used to get the item- See Also:
-
handleCachePutError
public void handleCachePutError(RuntimeException exception, Cache cache, Object key, @Nullable Object value) Description copied from interface:CacheErrorHandler
Handle the given runtime exception thrown by the cache provider when updating an item with the specifiedkey
andvalue
, possibly rethrowing it as a fatal exception.- Specified by:
handleCachePutError
in interfaceCacheErrorHandler
- Parameters:
exception
- the exception thrown by the cache providercache
- the cachekey
- the key used to update the itemvalue
- the value to associate with the key- See Also:
-
handleCacheEvictError
Description copied from interface:CacheErrorHandler
Handle the given runtime exception thrown by the cache provider when clearing an item with the specifiedkey
, possibly rethrowing it as a fatal exception.- Specified by:
handleCacheEvictError
in interfaceCacheErrorHandler
- Parameters:
exception
- the exception thrown by the cache providercache
- the cachekey
- the key used to clear the item
-
handleCacheClearError
Description copied from interface:CacheErrorHandler
Handle the given runtime exception thrown by the cache provider when clearing the specifiedCache
, possibly rethrowing it as a fatal exception.- Specified by:
handleCacheClearError
in interfaceCacheErrorHandler
- Parameters:
exception
- the exception thrown by the cache providercache
- the cache to clear
-
logCacheError
Log the specified message.- Parameters:
logger
- the loggermessage
- the messageex
- the exception
-