In a Spring WebFlux chain I use a map operation which sometimes may return null and I get a warning :
Return null or something nullable from lambda in transformation mehtod
.
I believe when data is null it doesn't actually map input to null
but it will raise an exception instead.
What is the best way to handle the scenario ?
Map method which is nullable :
public Pojo parseJson(String json) {
try {
// parse
return pojo;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
My reactive chain :
public Mono<Pojo> query(long id) {
Integer value = idMapper.getValue(id);
if (value != null) {
return repo.query(value)
Parse Method
|
v
.map(this::parse);
}
return null;
}