Check if FileLock is valid before using or releasing it
Change-Id: I23ba67b61b9b03772f33a929c080c0d02b8c8652
This commit is contained in:
parent
8eee800fb1
commit
a6da439b47
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue