mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3273 - file lock on win
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1089772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2f869e32d0
commit
47833b7fb1
|
@ -499,7 +499,7 @@ public class KahaStore implements Store {
|
||||||
String property = System.getProperty(key);
|
String property = System.getProperty(key);
|
||||||
if (null == property) {
|
if (null == property) {
|
||||||
if (!BROKEN_FILE_LOCK) {
|
if (!BROKEN_FILE_LOCK) {
|
||||||
lock = lockFile.getChannel().tryLock(0, lockFile.getChannel().size(), false);
|
lock = lockFile.getChannel().tryLock(0, Math.max(1, lockFile.getChannel().size()), false);
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
throw new StoreLockedExcpetion("Kaha Store " + directory.getName() + " is already opened by another application");
|
throw new StoreLockedExcpetion("Kaha Store " + directory.getName() + " is already opened by another application");
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -75,7 +75,7 @@ public final class ControlFile {
|
||||||
|
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
try {
|
try {
|
||||||
lock = randomAccessFile.getChannel().tryLock(0, randomAccessFile.getChannel().size(), false);
|
lock = randomAccessFile.getChannel().tryLock(0, Math.max(1, randomAccessFile.getChannel().size()), false);
|
||||||
} catch (OverlappingFileLockException e) {
|
} catch (OverlappingFileLockException e) {
|
||||||
throw IOExceptionSupport.create("Control file '" + file + "' could not be locked.",e);
|
throw IOExceptionSupport.create("Control file '" + file + "' could not be locked.",e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ public final class IndexManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized FileLock getLock() throws IOException {
|
public synchronized FileLock getLock() throws IOException {
|
||||||
return indexFile.getChannel().tryLock(0, indexFile.getChannel().size(), false);
|
return indexFile.getChannel().tryLock(0, Math.max(1, indexFile.getChannel().size()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1094,7 +1094,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
|
||||||
String property = System.getProperty(key);
|
String property = System.getProperty(key);
|
||||||
if (null == property) {
|
if (null == property) {
|
||||||
if (!BROKEN_FILE_LOCK) {
|
if (!BROKEN_FILE_LOCK) {
|
||||||
lock = lockFile.getChannel().tryLock(0, lockFile.getChannel().size(), false);
|
lock = lockFile.getChannel().tryLock(0, Math.max(1, lockFile.getChannel().size()), false);
|
||||||
if (lock == null) {
|
if (lock == null) {
|
||||||
result = false;
|
result = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class LockFile {
|
||||||
readFile = new RandomAccessFile(file, "rw");
|
readFile = new RandomAccessFile(file, "rw");
|
||||||
IOException reason = null;
|
IOException reason = null;
|
||||||
try {
|
try {
|
||||||
lock = readFile.getChannel().tryLock(0, readFile.getChannel().size(), false);
|
lock = readFile.getChannel().tryLock(0, Math.max(1, readFile.getChannel().size()), false);
|
||||||
} catch (OverlappingFileLockException e) {
|
} catch (OverlappingFileLockException e) {
|
||||||
reason = IOExceptionSupport.create("File '" + file + "' could not be locked.",e);
|
reason = IOExceptionSupport.create("File '" + file + "' could not be locked.",e);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
|
Loading…
Reference in New Issue