From 78e79614e5bf25e8579c739602f4abdf40941e05 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 10 Apr 2006 20:03:46 +0000 Subject: [PATCH] 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 --- .../apache/activeio/journal/active/ControlFile.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/activeio/activeio-core/src/main/java/org/apache/activeio/journal/active/ControlFile.java b/activeio/activeio-core/src/main/java/org/apache/activeio/journal/active/ControlFile.java index 3fc11b86f9..fca3a977e5 100644 --- a/activeio/activeio-core/src/main/java/org/apache/activeio/journal/active/ControlFile.java +++ b/activeio/activeio-core/src/main/java/org/apache/activeio/journal/active/ControlFile.java @@ -43,6 +43,7 @@ final public class ControlFile { private final RandomAccessFile file; private final FileChannel channel; private final ByteBufferPacket controlData; + private final static boolean brokenFileLock = "true".equals(System.getProperty("java.nio.channels.FileLock.broken", "false")); private long controlDataVersion=0; private FileLock lock; @@ -71,10 +72,12 @@ final public class ControlFile { throw new IOException("Journal is already opened by this application."); } - lock = channel.tryLock(); - if (lock == null) { - set.remove(canonicalPath); - throw new IOException("Journal is already opened by another application"); + if( !brokenFileLock ) { + lock = channel.tryLock(); + if (lock == null) { + set.remove(canonicalPath); + throw new IOException("Journal is already opened by another application"); + } } } }