[prev in list] [next in list] [prev in thread] [next in thread]
List: activemq-commits
Subject: svn commit: r808378 -
From: gtully () apache ! org
Date: 2009-08-27 11:46:21
Message-ID: 20090827114621.8B9DE23888FC () eris ! apache ! org
[Download RAW message or body]
Author: gtully
Date: Thu Aug 27 11:46:21 2009
New Revision: 808378
URL: http://svn.apache.org/viewvc?rev=808378&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2366 - new File needed on each \
lock attempt or master restart will see old lock history
Modified:
activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java
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=808378&r1=808377&r2=808378&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 Aug \
27 11:46:21 2009 @@ -55,18 +55,23 @@
}
IOHelper.mkdirs(file.getParentFile());
- if (readFile == null) {
- readFile = new RandomAccessFile(file, "rw");
- }
+
if (lock == null) {
+ readFile = new RandomAccessFile(file, "rw");
+ IOException reason = null;
try {
lock = readFile.getChannel().tryLock();
} catch (OverlappingFileLockException e) {
- throw IOExceptionSupport.create("File '" + file + "' could not be \
locked.",e); + reason = IOExceptionSupport.create("File '" + file + "' \
could not be locked.",e); }
if (lock != null) {
lockCounter++;
} else {
+ // new read file for next attempt
+ closeReadFile();
+ if (reason != null) {
+ throw reason;
+ }
throw new IOException("File '" + file + "' could not be locked.");
}
@@ -93,6 +98,14 @@
}
lock = null;
}
+ closeReadFile();
+
+ if( deleteOnUnlock ) {
+ file.delete();
+ }
+ }
+
+ private void closeReadFile() {
// close the file.
if (readFile != null) {
try {
@@ -102,9 +115,6 @@
readFile = null;
}
- if( deleteOnUnlock ) {
- file.delete();
- }
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic