Avoid use of Commons Logging in LoggingCacheErrorHandler public API
At present, creating LoggingCacheErrorHandler with custom logger requires use of Commons Logging API, as the appropriate constructor expects org.apache.commons.logging.Log instance. As Commons Logging is rarely the logging framework of choice in applications these days, interaction with its API might not be desirable. This commit adds LoggingCacheErrorHandler constructor that accepts logger name and thus avoids leaking out any details about the underlying logging framework.
This commit is contained in:
committed by
Juergen Hoeller
parent
182ba4ac29
commit
fb291379e4
@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.support.NoOpCache;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -84,4 +85,10 @@ class LoggingCacheErrorHandlerTests {
|
||||
verify(this.logger).warn("Cache 'NOOP' failed to get entry with key 'enigma'", exception);
|
||||
}
|
||||
|
||||
@Test
|
||||
void constructorWithLoggerName() {
|
||||
assertThatCode(() -> new LoggingCacheErrorHandler("org.apache.commons.logging.Log", true))
|
||||
.doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user