mirror of https://github.com/apache/activemq.git
The file lock implementation on some JVM/OS combinations is broken. See:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4883030 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4854085 If -Djava.nio.channels.FileLock.broken=true is now passed as an argument to the JVM, the actveio journal will avoid using that file locking APIs. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@393039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c852f0755b
commit
78e79614e5
|
@ -43,6 +43,7 @@ final public class ControlFile {
|
||||||
private final RandomAccessFile file;
|
private final RandomAccessFile file;
|
||||||
private final FileChannel channel;
|
private final FileChannel channel;
|
||||||
private final ByteBufferPacket controlData;
|
private final ByteBufferPacket controlData;
|
||||||
|
private final static boolean brokenFileLock = "true".equals(System.getProperty("java.nio.channels.FileLock.broken", "false"));
|
||||||
|
|
||||||
private long controlDataVersion=0;
|
private long controlDataVersion=0;
|
||||||
private FileLock lock;
|
private FileLock lock;
|
||||||
|
@ -71,10 +72,12 @@ final public class ControlFile {
|
||||||
throw new IOException("Journal is already opened by this application.");
|
throw new IOException("Journal is already opened by this application.");
|
||||||
}
|
}
|
||||||
|
|
||||||
lock = channel.tryLock();
|
if( !brokenFileLock ) {
|
||||||
if (lock == null) {
|
lock = channel.tryLock();
|
||||||
set.remove(canonicalPath);
|
if (lock == null) {
|
||||||
throw new IOException("Journal is already opened by another application");
|
set.remove(canonicalPath);
|
||||||
|
throw new IOException("Journal is already opened by another application");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue