protected void finalize() { if (lockFile != null) { logger.warn("In finalize. Lock file was not released: " + lockFile); } release(); }
/** * Create the lock file if it doesn't already exist and lock it with * an exclusive lock. * * @param lockFile the name of the lock file * @throws IOException if the file has already been locked or an I/O error * occurs. */ private LockFile(File lockFile) throws IOException { this.lockFile = lockFile; if (lockFile == null) { throw new IllegalArgumentException("Parameter lockFile is null"); } lockInternal(lockFile); try { raf = new RandomAccessFile(lockFile, "rw"); fc = raf.getChannel(); fl = fc.tryLock(); if (fl == null) throw new IOException("Lock file busy: " + lockFile); } finally { if (fl == null) { // An exception must have occurred. release(); } } }
} finally { if (lockFile != null) { lockFile.release(); lockFile = null;
freeList = null; if (lockFile != null) { lockFile.release(); lockFile = null;
lockFile.release(); lockFile = null;