Skip to content

Commit

Permalink
Close ObjectOutputStream in a finally clause
Browse files Browse the repository at this point in the history
  • Loading branch information
renuka-fernando authored and marcphilipp committed Oct 3, 2018
1 parent 144b084 commit 4c4663f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/org/junit/experimental/max/MaxHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ private MaxHistory(File storedResults) {
}

private void save() throws IOException {
ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(
fHistoryStore));
stream.writeObject(this);
stream.close();
ObjectOutputStream stream = null;
try {
stream = new ObjectOutputStream(new FileOutputStream(fHistoryStore));
stream.writeObject(this);
} finally {
if (stream != null) {
stream.close();
}
}
}

Long getFailureTimestamp(Description key) {
Expand Down

0 comments on commit 4c4663f

Please sign in to comment.