Skip to content

Commit dbe8f20

Browse files
vpavicsbrannen
authored andcommitted
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
1 parent ea4d9a2 commit dbe8f20

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/LoggingCacheErrorHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
* @author Adam Ostrožlík
3131
* @author Stephane Nicoll
32+
* @author Vedran Pavic
3233
* @since 5.3.16
3334
*/
3435
public class LoggingCacheErrorHandler implements CacheErrorHandler {
@@ -49,11 +50,19 @@ public LoggingCacheErrorHandler(Log logger, boolean logStacktrace) {
4950
this.logStacktrace = logStacktrace;
5051
}
5152

53+
/**
54+
* Create an instance.
55+
* @param logStacktrace whether to log stacktrace
56+
*/
57+
public LoggingCacheErrorHandler(boolean logStacktrace) {
58+
this(LogFactory.getLog(LoggingCacheErrorHandler.class), logStacktrace);
59+
}
60+
5261
/**
5362
* Create an instance that does not log stack traces.
5463
*/
5564
public LoggingCacheErrorHandler() {
56-
this(LogFactory.getLog(LoggingCacheErrorHandler.class), false);
65+
this(false);
5766
}
5867

5968

0 commit comments

Comments
 (0)