'Any workaround for Mono.just(null)
I'm in a situation where 3rd party library returns me
Mono<Predicate<Integer>>>
Inside library there is a map of
private Map<String, Mono<Predicate<Integer>>> predicateCache
Sometimes it returns me null inside Mono and I am getting an error which I can't handle.
predicateCache.get("someKey")
.map(predicate -> doSomething(predicate))
Is there any workaround to handle null values? use some default value or just do some error handling externally.
So how to handle similar scenarios when you don't have control over Mono.just(null) to change it at least Mono.justOrEmpty(). Because neither of below error handlings are helping
Mono.just((String) null)
.doOnError(ex -> System.out.println("handle error"))
.onErrorResume(ex -> Mono.empty())
.map(s -> doSomething(s))
.doOnError(ex -> System.out.println("handle error"))
.block();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
