Skip to content

Commit

Permalink
Close writer before System.exit (thanks jondrean)
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco Montenegro committed Aug 14, 2016
1 parent 22ede11 commit eae9b3c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/ruke/vrjassc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ public static void main(String[] args) {
} catch (Exception e) {
if (logWriter != null) {
logWriter.write(e.getMessage());
logWriter.close();
}

System.exit(OTHER_ERROR_STATUS_CODE);
}
}

Expand Down Expand Up @@ -140,7 +143,6 @@ public static void main(String[] args) {
writer = new PrintWriter(tmpFile, "UTF-8");

writer.write(compile.run(String.join("\n", toCompile)));

writer.close();

if (resultPath.endsWith("w3x") || resultPath.endsWith("w3m")) {
Expand Down Expand Up @@ -169,17 +171,21 @@ public static void main(String[] args) {

logWriter.write(System.lineSeparator() + toCompile.get(i).replace("\t", " "));
}

logWriter.close();
}

System.exit(COMPILE_ERROR_STATUS_CODE);
} catch (JmpqError jmpqe) {
if (logWriter != null) {
logWriter.write(jmpqe.getMessage());
logWriter.close();
}
System.exit(JMPQ_ERROR_STATUS_CODE);
} catch (IOException e) {
if (logWriter != null) {
logWriter.write("Could not load blizzard.j or common.j");
logWriter.close();
}
System.exit(IO_ERROR_STATUS_CODE);
} catch (Exception e) {
Expand All @@ -191,13 +197,11 @@ public static void main(String[] args) {
} else {
e.printStackTrace(logWriter);
}

logWriter.close();
}
System.exit(OTHER_ERROR_STATUS_CODE);
}

if (logWriter != null) {
logWriter.close();
}
}

}

0 comments on commit eae9b3c

Please sign in to comment.