Skip to content

Commit

Permalink
Ensure that all error logging is async
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Jan 7, 2025
1 parent 44b3aba commit ac8db4c
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,7 @@ public Trip generateRoute(OsmDataLayer layer, JsonObject tripConfig, ILatLon...
} catch (IOException e) {
throw new UncheckedIOException(e);
}
try (BufferedReader errors = p.errorReader()) {
errors.lines().forEach(Logging::error);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
logErrors(p);
final JsonObject data;
try (BufferedReader br = new BufferedReader(p.inputReader())) {
br.mark(40);
Expand Down Expand Up @@ -470,6 +466,11 @@ private static InputStream runCommand(String... args) throws IOException {
throw new JosmRuntimeException(interruptedException);
}
}
logErrors(p);
return p.getInputStream();
}

private static void logErrors(Process p) {
// Do not block here.
ForkJoinPool.commonPool().submit(() -> {
try (BufferedReader errors = p.errorReader()) {
Expand All @@ -478,6 +479,5 @@ private static InputStream runCommand(String... args) throws IOException {
throw new UncheckedIOException(e);
}
});
return p.getInputStream();
}
}

0 comments on commit ac8db4c

Please sign in to comment.