Skip to content
Snippets Groups Projects
Commit ee44d038 authored by Gerald Hübsch's avatar Gerald Hübsch Committed by Gerald Hübsch
Browse files

Fix assignment to final variable and buffered reader scope.

parent 4c51eca6
No related branches found
No related tags found
No related merge requests found
Pipeline #9034 passed
...@@ -109,17 +109,19 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -109,17 +109,19 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
String execstring = this.mediaconch_binary_path + " " + filePath + " -p " + profilePath; String execstring = this.mediaconch_binary_path + " " + filePath + " -p " + profilePath;
log.info("executing: " + execstring); log.info("executing: " + execstring);
final AtomicBoolean fuse = new AtomicBoolean(true); final AtomicBoolean fuse = new AtomicBoolean(true);
final BufferedReader procOutputReader = null;
try { try {
Process p = Runtime.getRuntime().exec(execstring); final Process p = Runtime.getRuntime().exec(execstring);
procOutputReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
final ArrayList<String> procOutputLineList = new ArrayList<String>(); final ArrayList<String> procOutputLineList = new ArrayList<String>();
// prepare thread that reads the bulky output (>> 100kByte in some cases) to prevent the buffered reader from reaching its capacity limit // prepare thread that reads the bulky output (>> 100kByte in some cases) to prevent the buffered reader from reaching its capacity limit
Thread procOutputReaderThread = new Thread() { Thread procOutputReaderThread = new Thread() {
public void run() { public void run() {
BufferedReader procOutputReader = null;
try { try {
procOutputReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String nextLine = ""; String nextLine = "";
while (fuse.get() && (nextLine = procOutputReader.readLine()) != null) { while (fuse.get() && (nextLine = procOutputReader.readLine()) != null) {
procOutputLineList.add(nextLine); procOutputLineList.add(nextLine);
...@@ -130,6 +132,16 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -130,6 +132,16 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
} finally { } finally {
// ensure this thread terminates under all circumstances // ensure this thread terminates under all circumstances
fuse.set(false); fuse.set(false);
// cleanup all resources
if (procOutputReader != null) {
try {
procOutputReader.close();
} catch (IOException e) {
log.error("ERROR: closing the reader stream failed, " + e.getMessage());
}
}
} }
if (isDumpValidationResultToStdOut()) { if (isDumpValidationResultToStdOut()) {
...@@ -181,11 +193,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP ...@@ -181,11 +193,6 @@ public class SLUBMatroskaFFV1FormatValidationPlugin implements FormatValidationP
} finally { } finally {
// ensure the while loop of procOutputReaderThread terminates under all circumstances // ensure the while loop of procOutputReaderThread terminates under all circumstances
fuse.set(false); fuse.set(false);
// cleanup all resources
if (procOutputReader != null) {
procOutputReader.close();
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment