Skip to content

Commit

Permalink
🚱 Make sure the BufferedReader gets closed
Browse files Browse the repository at this point in the history
  • Loading branch information
erinzm committed Aug 21, 2015
1 parent dd0de6b commit 9fb54f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/replicatorg/app/util/PythonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ public static Version checkVersion() {
*/
public static Version checkVersion(String path) {
ProcessBuilder pb = new ProcessBuilder(path,"-V");
BufferedReader reader = null;
pb.redirectErrorStream(true);
try {
Process p = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
int returnCode = p.waitFor();
if (returnCode != 0) {
return null;
Expand All @@ -246,6 +247,12 @@ public static Version checkVersion(String path) {
}
} catch (Exception e) {
Base.logger.log(Level.SEVERE,"Error attempting to detect python",e);
} finally {
try {
reader.close();
} catch (IOException e) {
Base.logger.log(Level.SEVERE, "Error closing BufferedReader when attempting to detect Python", e);
}
}
return null;
}
Expand Down

0 comments on commit 9fb54f8

Please sign in to comment.