提交 0ea812f8 编写于 作者: M mchung

7032589: FileHandler leaking file descriptor of the file lock

Reviewed-by: forax, dcubed
上级 97031c7e
...@@ -409,22 +409,25 @@ public class FileHandler extends StreamHandler { ...@@ -409,22 +409,25 @@ public class FileHandler extends StreamHandler {
// Try the next file. // Try the next file.
continue; continue;
} }
boolean available;
try { try {
FileLock fl = fc.tryLock(); available = fc.tryLock() != null;
if (fl == null) {
// We failed to get the lock. Try next file.
continue;
}
// We got the lock OK. // We got the lock OK.
} catch (IOException ix) { } catch (IOException ix) {
// We got an IOException while trying to get the lock. // We got an IOException while trying to get the lock.
// This normally indicates that locking is not supported // This normally indicates that locking is not supported
// on the target directory. We have to proceed without // on the target directory. We have to proceed without
// getting a lock. Drop through. // getting a lock. Drop through.
available = true;
}
if (available) {
// We got the lock. Remember it.
locks.put(lockFileName, lockFileName);
break;
} }
// We got the lock. Remember it.
locks.put(lockFileName, lockFileName); // We failed to get the lock. Try next file.
break; fc.close();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册