I am trying to validate the values of a list
using a reactor.core.publisher.Flux
inside a try catch
, but when map
throws the exception the catch
doesn't catch it at all. I don't really understand what's happening here. Some help would be appreciate.
This is exactly what I am trying to do:
public Flux<Something> execute(final List<Line> lines) {
try {
return this.getFlux(lines)
.map(line -> this.validateLine(line))//this throws my custom exception if the condition applies
.map(line -> this.doSomething(line))
.map(line -> this.doSomethingElse(line));
} catch (myCustomException e) {
return something;
}
}
I can see the validate
method works well and throws the exception by debugging but the catch
doesn't seem to be working and I can't see what is wrong.
You would need a terminal operation applied onto the end of the stream. Streams are evaluated lazily.