Internal: Pending Task listing should account for task being nulled

This caused by #9671 and #9621 working together and cause an NPE
This commit is contained in:
Boaz Leskes 2015-02-12 15:50:12 +01:00
parent ce24e10783
commit 35f6496694
1 changed files with 7 additions and 3 deletions

View File

@ -296,12 +296,16 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
for (PrioritizedEsThreadPoolExecutor.Pending pending : pendings) { for (PrioritizedEsThreadPoolExecutor.Pending pending : pendings) {
final String source; final String source;
final long timeInQueue; final long timeInQueue;
if (pending.task instanceof TimedPrioritizedRunnable) { // we have to capture the task as it will be nulled after execution and we don't want to change while we check things here.
TimedPrioritizedRunnable runnable = (TimedPrioritizedRunnable) pending.task; final Object task = pending.task;
if (task == null) {
continue;
} else if (task instanceof TimedPrioritizedRunnable) {
TimedPrioritizedRunnable runnable = (TimedPrioritizedRunnable) task;
source = runnable.source(); source = runnable.source();
timeInQueue = runnable.timeSinceCreatedInMillis(); timeInQueue = runnable.timeSinceCreatedInMillis();
} else { } else {
assert false : "expected TimedPrioritizedRunnable got " + pending.task.getClass(); assert false : "expected TimedPrioritizedRunnable got " + task.getClass();
source = "unknown"; source = "unknown";
timeInQueue = 0; timeInQueue = 0;
} }