Merge pull request #2669 from ManfredKarrer/close-printwriter-before-rename-temp-file

Close printWriter before renaming temp file
This commit is contained in:
Christoph Atteneder 2019-04-08 10:42:37 +02:00 committed by GitHub
commit 33a04bba57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,6 +79,13 @@ public class JsonFileManager {
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());