}
public void release(boolean closeChannel) {
+ if (lock==null)
+ return;
try {
// channel.close should be called before release() for rigourous locking.
- if (rafile!=null && rafile.getFD().valid() && rafile.getChannel()!=null && lock.isValid()) {
+ if (lock.isValid() && rafile!=null && rafile.getFD().valid() && rafile.getChannel()!=null) {
if (closeChannel && rafile.getChannel().isOpen()) {
rafile.close();
rafile=null;
+ } else {
+ // just release the lock without doing anything to the channe;l
+ if (lock!=null && lock.isValid())
+ lock.release();
}
- if (lock!=null && lock.isValid())
- lock.release();
-
}
} catch (IOException e) {
log.warn("Whilst releasing lock",e);
return null;
}
+ public boolean isTargetLockFile(File afile) {
+ if (isLocked() && target.equals(afile))
+ return true;
+ return false;
+ }
+
}