From: jprocter Date: Mon, 24 Oct 2005 13:31:23 +0000 (+0000) Subject: added automatic channel closure for failed locks. (suggest this class becomes a singl... X-Git-Tag: Release_0.2~446 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c724c5585a7d245621daee3022f0b10a14ccb3ba;p=vamsas.git added automatic channel closure for failed locks. (suggest this class becomes a singleton?) git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@74 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/client/simpleclient/Lock.java b/src/org/vamsas/client/simpleclient/Lock.java index ab159ba..300ea0e 100644 --- a/src/org/vamsas/client/simpleclient/Lock.java +++ b/src/org/vamsas/client/simpleclient/Lock.java @@ -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());