Propagate method error in some cases of reactive findInCaches errors
In a Cacheable reactive method, if an exception is propagated from both the method and the caching infrastructure, an NPE could previously surface due to the `CacheAspectSupport` attempting to perform an `onErrorResume` with a `null`. This change ensures that in such a case the user-level exception from the method is propagated instead. Closes gh-33492
This commit is contained in:
@@ -1141,7 +1141,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);
|
||||
@@ -1155,7 +1156,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);
|
||||
|
||||
Reference in New Issue
Block a user