Closed
Description
In the CacheAspectSupport.findInCaches method
CompletableFuture<?> cachedFuture = cache.retrieve(key);
spring cache result is null, spring redis cache result is CompletableFuture.completedFuture(null) causing result return error
@Nullable
public Object findInCaches(CacheOperationContext context, Cache cache, Object key) {
ReactiveAdapter adapter = this.registry.getAdapter(context.getMethod().getReturnType());
if (adapter != null) {
CompletableFuture<?> cachedFuture = cache.retrieve(key);
if (cachedFuture == null) {
return null;
}
if (adapter.isMultiValue()) {
return adapter.fromPublisher(Flux.from(Mono.fromFuture(cachedFuture))
.flatMap(v -> (v instanceof Iterable<?> iv ? Flux.fromIterable(iv) : Flux.just(v))));
}
else {
return adapter.fromPublisher(Mono.fromFuture(cachedFuture));
}
}
return NOT_HANDLED;
}