1111import java .nio .channels .OverlappingFileLockException ;
1212import java .nio .file .Files ;
1313import java .nio .file .StandardOpenOption ;
14+ import java .nio .file .attribute .PosixFilePermission ;
1415import java .nio .file .attribute .PosixFilePermissions ;
16+ import java .util .Arrays ;
1517import java .util .Date ;
18+ import java .util .HashSet ;
1619
20+ import static java .nio .file .StandardOpenOption .*;
1721import static net .openhft .affinity .impl .VanillaCpuLayout .MAX_CPUS_SUPPORTED ;
1822
1923/**
@@ -54,7 +58,7 @@ private boolean isLockFree(File file, int id) {
5458
5559 //does another process have the lock?
5660 try {
57- FileChannel fc = FileChannel .open (file .toPath (), StandardOpenOption . WRITE );
61+ FileChannel fc = FileChannel .open (file .toPath (), WRITE );
5862 FileLock fileLock = fc .tryLock ();
5963 if (fileLock == null ) {
6064 return false ;
@@ -77,8 +81,9 @@ public boolean obtainLock(int id, String metaInfo) throws IOException {
7781 return false ;
7882 }
7983
80- FileChannel fc = FileChannel .open (file .toPath (), StandardOpenOption .CREATE_NEW ,
81- StandardOpenOption .WRITE , StandardOpenOption .READ , StandardOpenOption .SYNC );
84+ FileChannel fc = FileChannel .open (file .toPath (),
85+ new HashSet <>(Arrays .asList (CREATE_NEW , WRITE , READ , SYNC )),
86+ PosixFilePermissions .asFileAttribute (PosixFilePermissions .fromString ("rw-rw-rw-" )));
8287 FileLock fl = fc .tryLock ();
8388
8489 if (fl == null ) {
0 commit comments