Add a RandomAccessFile which doesn't resource leak on a GC, https://github.com/OpenHFT/Chronicle-Core/issues/108

This commit is contained in:
Peter Lawrey
2020-05-07 11:33:10 +01:00
parent cf0b6cc7e1
commit 9b1d3f6393
2 changed files with 5 additions and 3 deletions
@@ -44,8 +44,9 @@ public class Builder {
This will only work if the user is an admin on windows.
*/
file.setWritable(true);//just in case relative path was used.
RandomAccessFile raf = new RandomAccessFile(file, "rw");
raf.close();//allows closing the file access on windows. forcing to close access. Only works for admin-access.
try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
//allows closing the file access on windows. forcing to close access. Only works for admin-access.
}
}
//file.delete(); //isnt guaranteed on windows.