added automatic channel closure for failed locks. (suggest this class becomes a singl...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 24 Oct 2005 13:31:23 +0000 (13:31 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 24 Oct 2005 13:31:23 +0000 (13:31 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@74 be28352e-c001-0410-b1a7-c7978e42abec

src/org/vamsas/client/simpleclient/Lock.java

index ab159ba..300ea0e 100644 (file)
@@ -33,6 +33,9 @@ public class Lock {
         }
       
       lock = (rafile=new RandomAccessFile(lockfile,"rw")).getChannel().tryLock();
+      if (lock==null || !lock.isValid())
+        // failed to get lock. Close the file channel
+        rafile.getChannel().close();
     } catch (FileNotFoundException e) {
       System.err.println("Error! Couldn't create a lockfile at "
           + lockfile.getAbsolutePath());