fixed subtle bug in closeChannel behaviour on lock release and debug logging.
[vamsas.git] / src / uk / ac / vamsas / client / simpleclient / FileLock.java
index 4ab0a65..ef29f47 100644 (file)
@@ -116,16 +116,18 @@ public class FileLock extends Lock {
   public void release(boolean closeChannel) {
     if (!isLocked())
       return;
-    if (log.isDebugEnabled())
-      log.debug("Releasing advisory lock on "+target);
-    if (closeChannel) {
-      if (rafile!=null) 
+    if (rafile!=null) {
+      if (closeChannel) {
         try {
           rafile.close();
         } catch (Exception e) {
           log.debug("Unexpected exception whilst closing RandomAccessFile on "+target, e);
         }
-        rafile=null; 
+        rafile=null; // do not hold reference to rafile anymore either
+      }
+      if (log.isDebugEnabled())
+        log.debug("Releasing advisory lock on "+target);
+      // TODO: LATER: verify this change in closeChannel semantics really is correct - ArchiveClient works correctly
     }
     tidy();
   }