Currently I have the following code:
private Flux<String> tailFileManual(Path path) {
final File file = path.toFile();
return Flux.using(
() -> new BufferedReader(new FileReader(file)),
reader -> Flux.create(emitter -> {
while (true) {
final String line = reader.readLine();
if (line == null) {
Thread.sleep(250);
} else if (line.equals("null")) {
emitter.complete();
break;
} else {
emitter.next(line);
}
}
}),
BufferedReader::close
);
}
Running with latest reactor-core (3.1.7), java complains that I have to wrap every thrown type (in this example IOException
) with try-catch. Now this code runs as it in rx-java2
using Flowable.using
, but for some reason Reactor
is forcing me to manually wrap every possible thrown error in try-catch, making this code verbose... Is there something I'm missing?
I don't want to wrap FileReader
, Thread.sleep
and BufferedReader::close
with try-catch, thus missing the whole point of short lambda expressions