https://issues.apache.org/jira/browse/AMQ-3237 - FileLock.tryLock() doesn't work well in all environments

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1084533 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2011-03-23 10:43:21 +00:00
parent 8d65328f0f
commit 68bcac109a
5 changed files with 5 additions and 5 deletions

View File

@ -499,7 +499,7 @@ public class KahaStore implements Store {
String property = System.getProperty(key);
if (null == property) {
if (!BROKEN_FILE_LOCK) {
lock = lockFile.getChannel().tryLock();
lock = lockFile.getChannel().tryLock(0, lockFile.getChannel().size(), false);
if (lock == null) {
throw new StoreLockedExcpetion("Kaha Store " + directory.getName() + " is already opened by another application");
} else

View File

@ -75,7 +75,7 @@ public final class ControlFile {
if (lock == null) {
try {
lock = randomAccessFile.getChannel().tryLock();
lock = randomAccessFile.getChannel().tryLock(0, randomAccessFile.getChannel().size(), false);
} catch (OverlappingFileLockException e) {
throw IOExceptionSupport.create("Control file '" + file + "' could not be locked.",e);
}

View File

@ -188,7 +188,7 @@ public final class IndexManager {
}
public synchronized FileLock getLock() throws IOException {
return indexFile.getChannel().tryLock();
return indexFile.getChannel().tryLock(0, indexFile.getChannel().size(), false);
}

View File

@ -1091,7 +1091,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
String property = System.getProperty(key);
if (null == property) {
if (!BROKEN_FILE_LOCK) {
lock = lockFile.getChannel().tryLock();
lock = lockFile.getChannel().tryLock(0, lockFile.getChannel().size(), false);
if (lock == null) {
result = false;
} else {

View File

@ -63,7 +63,7 @@ public class LockFile {
readFile = new RandomAccessFile(file, "rw");
IOException reason = null;
try {
lock = readFile.getChannel().tryLock();
lock = readFile.getChannel().tryLock(0, readFile.getChannel().size(), false);
} catch (OverlappingFileLockException e) {
reason = IOExceptionSupport.create("File '" + file + "' could not be locked.",e);
} catch (IOException ioe) {