Skip to content

Commit

Permalink
Code review: do not reuse a static buffered reader to scan the output…
Browse files Browse the repository at this point in the history
… file

Signed-off-by: Paul Gooderham <turkeyonmarblerye@gmail.com>
  • Loading branch information
turkeylurkey committed Nov 20, 2024
1 parent b736021 commit b75e402
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/test/java/io/openliberty/tools/intellij/it/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,24 +575,11 @@ public static void copyDirectory(String sourceDirectoryLocation, String destinat
* Test to see if there has been a fatal error and JUnit should be stopped.
* This searches the output of this JUnit run for SocketTimeoutException which
* has been identified as a fatal error and occurs during the Mac tests.
* It is set up as a static reader so that we do not reread the whole file
* after each test.
*/
final static String outputFile = System.getenv("JUNIT_OUTPUT_TXT");
final static BufferedReader reader;

static {
BufferedReader reader1;
try {
reader1 = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile)));
} catch (FileNotFoundException e) {
reader1 = null;
}
reader = reader1;
}

public static synchronized void detectFatalError() {
final String outputFile = System.getenv("JUNIT_OUTPUT_TXT");
try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile)));
// Flush our output and then wait briefly for the process running 'tee' to flush output to the
// file that the buffered reader is reading.
System.out.flush();
Expand All @@ -604,7 +591,7 @@ public static synchronized void detectFatalError() {
System.exit(1);
}
}
} catch (IOException | InterruptedException | NullPointerException e) {
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
Expand Down

0 comments on commit b75e402

Please sign in to comment.