diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java index 6c60f0330b1eba083a193df6553fa39c7a957cb6..27f60236c38557a1ec3ab133b6316a4ff6d392ab 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBMatroskaFFV1FormatValidationPlugin.java @@ -108,10 +108,11 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP private void callMediaconch(String filePath, String profilePath) { String execstring = this.mediaconch_binary_path + " " + filePath + " -p " + profilePath; log.info("executing: " + execstring); - final AtomicBoolean fuse = new AtomicBoolean(true); + final AtomicBoolean fuse = new AtomicBoolean(true); + final BufferedReader procOutputReader = null; try { Process p = Runtime.getRuntime().exec(execstring); - BufferedReader procOutputReader = new BufferedReader(new InputStreamReader(p.getInputStream())); + procOutputReader = new BufferedReader(new InputStreamReader(p.getInputStream())); final ArrayList<String> procOutputLineList = new ArrayList<String>(); @@ -170,8 +171,7 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP System.out.println("MEDIACONCH line: " + line); validationLog.add(line); log.info( line ); - } - procOutputReader.close(); + } } catch (IOException e) { log.error("(actual) mediaconch not available, path=" + this.mediaconch_binary_path + ", " , e.getMessage()); System.out.println("ERROR: (actual) mediaconch not available, path=" + this.mediaconch_binary_path + ", " + e.getMessage()); @@ -181,6 +181,11 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP } finally { // ensure the while loop of procOutputReaderThread terminates under all circumstances fuse.set(false); + + // cleanup all resources + if (procOutputReader != null) { + procOutputReader.close(); + } } }