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) {
final String source;
final long timeInQueue;
if (pending.task instanceof TimedPrioritizedRunnable) {
TimedPrioritizedRunnable runnable = (TimedPrioritizedRunnable) pending.task;
// 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.
final Object task = pending.task;
if (task == null) {
continue;
} else if (task instanceof TimedPrioritizedRunnable) {
TimedPrioritizedRunnable runnable = (TimedPrioritizedRunnable) task;
source = runnable.source();
timeInQueue = runnable.timeSinceCreatedInMillis();
} else {
assert false : "expected TimedPrioritizedRunnable got " + pending.task.getClass();
assert false : "expected TimedPrioritizedRunnable got " + task.getClass();
source = "unknown";
timeInQueue = 0;
}