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:
Hiram R. Chirino 2006-04-10 20:03:46 +00:00
parent c852f0755b
commit 78e79614e5
1 changed files with 7 additions and 4 deletions

View File

@ -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,6 +72,7 @@ final public class ControlFile {
throw new IOException("Journal is already opened by this application."); throw new IOException("Journal is already opened by this application.");
} }
if( !brokenFileLock ) {
lock = channel.tryLock(); lock = channel.tryLock();
if (lock == null) { if (lock == null) {
set.remove(canonicalPath); set.remove(canonicalPath);
@ -79,6 +81,7 @@ final public class ControlFile {
} }
} }
} }
}
/** /**
* Un locks the control file. * Un locks the control file.