Check if FileLock is valid before using or releasing it

Change-Id: I23ba67b61b9b03772f33a929c080c0d02b8c8652
This commit is contained in:
Matthias Sohn 2023-02-22 02:42:32 +01:00
parent 8eee800fb1
commit a6da439b47
1 changed files with 2 additions and 2 deletions

View File

@ -1649,7 +1649,7 @@ boolean lock() {
f = new RandomAccessFile(pidFile.toFile(), "rw"); //$NON-NLS-1$
channel = f.getChannel();
lock = channel.tryLock();
if (lock == null) {
if (lock == null || !lock.isValid()) {
failedToLock();
return false;
}
@ -1738,7 +1738,7 @@ private String getHostName() {
public void close() {
boolean wasLocked = false;
try {
if (lock != null) {
if (lock != null && lock.isValid()) {
lock.release();
wasLocked = true;
}