Simplify creation of LoggingCacheErrorHandler with logged stacktrace

At present, creating a LoggingCacheErrorHandler that logs stack traces
also requires supplying the logger to be used. This might be
inconvenient for some users, as it requires usage of the Commons
Logging API.

This commit simplifies creation of such as LoggingCacheErrorHandler
instance by adding a constructor that only accepts a boolean flag
indicating whether to log stack traces.

Closes gh-28670
This commit is contained in:
Vedran Pavic 2022-06-17 16:25:23 +02:00 committed by Sam Brannen
parent ea4d9a20ac
commit dbe8f200a9
1 changed files with 10 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import org.springframework.util.Assert;
*
* @author Adam Ostrožlík
* @author Stephane Nicoll
* @author Vedran Pavic
* @since 5.3.16
*/
public class LoggingCacheErrorHandler implements CacheErrorHandler {
@ -49,11 +50,19 @@ public class LoggingCacheErrorHandler implements CacheErrorHandler {
this.logStacktrace = logStacktrace;
}
/**
* Create an instance.
* @param logStacktrace whether to log stacktrace
*/
public LoggingCacheErrorHandler(boolean logStacktrace) {
this(LogFactory.getLog(LoggingCacheErrorHandler.class), logStacktrace);
}
/**
* Create an instance that does not log stack traces.
*/
public LoggingCacheErrorHandler() {
this(LogFactory.getLog(LoggingCacheErrorHandler.class), false);
this(false);
}