Skip to content

Commit

Permalink
Merge pull request #2669 from ManfredKarrer/close-printwriter-before-…
Browse files Browse the repository at this point in the history
…rename-temp-file

Close printWriter before renaming temp file
  • Loading branch information
ripcurlx authored Apr 8, 2019
2 parents 2f3dd40 + 7d56201 commit 33a04bb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/src/main/java/bisq/common/storage/JsonFileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public void writeToDisc(String json, String fileName) {
printWriter = new PrintWriter(tempFile);
printWriter.println(json);

// This close call and comment is borrowed from FileManager. Not 100% sure it that is really needed but
// seems that had fixed in the past and we got reported issues on Windows so that fix might be still
// required.
// Close resources before replacing file with temp file because otherwise it causes problems on windows
// when rename temp file
printWriter.close();

FileUtil.renameFile(tempFile, jsonFile);
} catch (Throwable t) {
log.error("storageFile " + jsonFile.toString());
Expand Down

0 comments on commit 33a04bb

Please sign in to comment.