SOLR-10376: Handle InterruptedException thrown by lock.lockInterruptibly() separately

This commit is contained in:
Shalin Shekhar Mangar 2017-04-28 11:48:14 +05:30
parent 12933ee4a7
commit 50fdf6ac7a

View File

@ -100,25 +100,34 @@ public class OverseerTriggerThread implements Runnable, Closeable {
while (true) {
Map<String, AutoScaling.Trigger> copy = null;
try {
// this can throw InterruptedException and we don't want to unlock if it did, so we keep this outside
// of the try/finally block
updateLock.lockInterruptibly();
if (znodeVersion == lastZnodeVersion) {
updated.await();
try {
if (znodeVersion == lastZnodeVersion) {
updated.await();
// are we closed?
if (isClosed) break;
// are we closed?
if (isClosed) break;
// spurious wakeup?
if (znodeVersion == lastZnodeVersion) continue;
lastZnodeVersion = znodeVersion;
// spurious wakeup?
if (znodeVersion == lastZnodeVersion) continue;
lastZnodeVersion = znodeVersion;
}
copy = new HashMap<>(activeTriggers);
} catch (InterruptedException e) {
// Restore the interrupted status
Thread.currentThread().interrupt();
log.warn("Interrupted", e);
break;
} finally {
updateLock.unlock();
}
copy = new HashMap<>(activeTriggers);
} catch (InterruptedException e) {
// Restore the interrupted status
Thread.currentThread().interrupt();
log.warn("Interrupted", e);
break;
} finally {
updateLock.unlock();
}
Set<String> managedTriggerNames = scheduledTriggers.getScheduledTriggerNames();