changeset 1304:4efff1f3f56f

7901577: JMH file lock works only for the current user, prevents any future runs by other users
author shade
date Wed, 13 Jan 2016 01:49:11 +0300
parents bcec9a03787f
children 2290f828ce5c
files jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Thu Oct 29 20:25:22 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Wed Jan 13 01:49:11 2016 +0300
@@ -180,7 +180,13 @@
         FileChannel channel = null;
         FileLock lock = null;
         try {
-            channel = new RandomAccessFile(JMH_LOCK_FILE, "rw").getChannel();
+            // Make sure the lock file is world-writeable, otherwise the lock file created by current
+            // user would not work for any other user, always failing the run.
+            File file = new File(JMH_LOCK_FILE);
+            file.createNewFile();
+            file.setWritable(true, false);
+
+            channel = new RandomAccessFile(file, "rw").getChannel();
 
             try {
                 lock = channel.tryLock();