git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1326252 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2012-04-15 04:50:53 +00:00
parent 2f0ef2e670
commit 50d3e8e09a
1 changed files with 36 additions and 25 deletions

View File

@ -56,9 +56,13 @@ public class LockFile {
}
IOHelper.mkdirs(file.getParentFile());
synchronized (LockFile.class) {
if (System.getProperty(getVmLockKey()) != null) {
throw new IOException("File '" + file + "' could not be locked as lock is already held for this jvm.");
}
System.setProperty(getVmLockKey(), new Date().toString());
}
try {
if (lock == null) {
readFile = new RandomAccessFile(file, "rw");
IOException reason = null;
@ -82,6 +86,13 @@ public class LockFile {
}
}
} finally {
synchronized (LockFile.class) {
if (lock == null) {
System.getProperties().remove(getVmLockKey());
}
}
}
}
/**