Author: dejanb
Date: Thu Apr  7 08:30:53 2011
New Revision: 1089772

URL: http://svn.apache.org/viewvc?rev=1089772&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3273 - file lock on win

Modified:
    
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
    
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ControlFile.java
    
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexManager.java
    
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java

Modified: 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java?rev=1089772&r1=1089771&r2=1089772&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
 (original)
+++ 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
 Thu Apr  7 08:30:53 2011
@@ -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(0, 
lockFile.getChannel().size(), false);
+                        lock = lockFile.getChannel().tryLock(0, Math.max(1, 
lockFile.getChannel().size()), false);
                         if (lock == null) {
                             throw new StoreLockedExcpetion("Kaha Store " + 
directory.getName() + "  is already opened by another application");
                         } else

Modified: 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ControlFile.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ControlFile.java?rev=1089772&r1=1089771&r2=1089772&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ControlFile.java
 (original)
+++ 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/ControlFile.java
 Thu Apr  7 08:30:53 2011
@@ -75,7 +75,7 @@ public final class ControlFile {
 
         if (lock == null) {
             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) {
                 throw IOExceptionSupport.create("Control file '" + file + "' 
could not be locked.",e);
             }

Modified: 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexManager.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexManager.java?rev=1089772&r1=1089771&r2=1089772&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexManager.java
 (original)
+++ 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/index/IndexManager.java
 Thu Apr  7 08:30:53 2011
@@ -188,7 +188,7 @@ public final class IndexManager {
     }
     
     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);
     }
 
 

Modified: 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java?rev=1089772&r1=1089771&r2=1089772&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
 (original)
+++ 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
 Thu Apr  7 08:30:53 2011
@@ -1094,7 +1094,7 @@ public class AMQPersistenceAdapter imple
             String property = System.getProperty(key);
             if (null == property) {
                 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) {
                         result = false;
                     } else {

Modified: 
activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java?rev=1089772&r1=1089771&r2=1089772&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java 
(original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java 
Thu Apr  7 08:30:53 2011
@@ -63,7 +63,7 @@ public class LockFile {
             readFile = new RandomAccessFile(file, "rw");
             IOException reason = null;
             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) {
                 reason = IOExceptionSupport.create("File '" + file + "' could 
not be locked.",e);
             } catch (IOException ioe) {


Reply via email to