Merge branch '6.1.x'
This commit is contained in:
@@ -1155,7 +1155,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
||||
.onErrorResume(RuntimeException.class, ex -> {
|
||||
try {
|
||||
getErrorHandler().handleCacheGetError((RuntimeException) ex, cache, key);
|
||||
return evaluate(null, invoker, method, contexts);
|
||||
Object e = evaluate(null, invoker, method, contexts);
|
||||
return (e != null ? e : Flux.error((RuntimeException) ex));
|
||||
}
|
||||
catch (RuntimeException exception) {
|
||||
return Flux.error(exception);
|
||||
@@ -1169,7 +1170,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
||||
.onErrorResume(RuntimeException.class, ex -> {
|
||||
try {
|
||||
getErrorHandler().handleCacheGetError((RuntimeException) ex, cache, key);
|
||||
return evaluate(null, invoker, method, contexts);
|
||||
Object e = evaluate(null, invoker, method, contexts);
|
||||
return (e != null ? e : Mono.error((RuntimeException) ex));
|
||||
}
|
||||
catch (RuntimeException exception) {
|
||||
return Mono.error(exception);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -145,6 +146,23 @@ class ReactiveCachingTests {
|
||||
assertThat(r1).as("cacheFlux blockFirst").isEqualTo(2L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cacheErrorHandlerWithLoggingCacheErrorHandlerAndMethodError() {
|
||||
AnnotationConfigApplicationContext ctx =
|
||||
new AnnotationConfigApplicationContext(ExceptionCacheManager.class, ReactiveFailureCacheableService.class, ErrorHandlerCachingConfiguration.class);
|
||||
ReactiveCacheableService service = ctx.getBean(ReactiveCacheableService.class);
|
||||
|
||||
Object key = new Object();
|
||||
StepVerifier.create(service.cacheMono(key))
|
||||
.expectErrorMessage("mono service error")
|
||||
.verify();
|
||||
|
||||
key = new Object();
|
||||
StepVerifier.create(service.cacheFlux(key))
|
||||
.expectErrorMessage("flux service error")
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
void cacheErrorHandlerWithSimpleCacheErrorHandler() {
|
||||
AnnotationConfigApplicationContext ctx =
|
||||
@@ -214,6 +232,20 @@ class ReactiveCachingTests {
|
||||
}
|
||||
}
|
||||
|
||||
@CacheConfig(cacheNames = "first")
|
||||
static class ReactiveFailureCacheableService extends ReactiveCacheableService {
|
||||
|
||||
@Cacheable
|
||||
Mono<Long> cacheMono(Object arg) {
|
||||
return Mono.error(new IllegalStateException("mono service error"));
|
||||
}
|
||||
|
||||
@Cacheable
|
||||
Flux<Long> cacheFlux(Object arg) {
|
||||
return Flux.error(new IllegalStateException("flux service error"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableCaching
|
||||
|
||||
Reference in New Issue
Block a user