From c8c7209ad474cce3a5c0e998644ab0eaa0ce9912 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 12 Jan 2007 15:34:27 +0000 Subject: [PATCH] fixed subtle bug in closeChannel behaviour on lock release and debug logging. 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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/uk/ac/vamsas/client/simpleclient/FileLock.java b/src/uk/ac/vamsas/client/simpleclient/FileLock.java index 4ab0a65..ef29f47 100644 --- a/src/uk/ac/vamsas/client/simpleclient/FileLock.java +++ b/src/uk/ac/vamsas/client/simpleclient/FileLock.java @@ -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(); } -- 1.7.10.2