fixed subtle bug in closeChannel behaviour on lock release and debug logging.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 12 Jan 2007 15:34:27 +0000 (15:34 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 12 Jan 2007 15:34:27 +0000 (15:34 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@334 be28352e-c001-0410-b1a7-c7978e42abec

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();
   }