Skip to content

Commit

Permalink
fix for #923
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Jun 21, 2022
1 parent 44ff1a7 commit e06acf4
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.*;
import java.util.List;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand All @@ -23,7 +23,19 @@ public static Integer process(List<String> cmd) {
String message = "error message cannot be retrieved";
try {
builder = new ProcessBuilder(cmd);
builder.redirectErrorStream(true);
process = builder.start();

BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String output = null;
String previousOutput = null;
while (null != (output = br.readLine())) {
// writing the pdfalto stderr in the GROBID logs as warning
if (!output.equals(previousOutput)) {
LOGGER.warn("pdfalto stderr: " + output);
previousOutput = output;
}
}
exit = process.waitFor();
message = IOUtils.toString(process.getErrorStream(), UTF_8);

Expand Down

0 comments on commit e06acf4

Please sign in to comment.