* JobQueue: Prevet NPE at shutdown (thanks liberty)

This commit is contained in:
zzz
2011-02-13 20:28:46 +00:00
parent 41d8177340
commit 1f702f1eb1

View File

@ -227,10 +227,14 @@ public class JobQueue {
} }
public long getMaxLag() { public long getMaxLag() {
// first job is the one that has been waiting the longest
Job j = _readyJobs.peek(); Job j = _readyJobs.peek();
if (j == null) return 0; if (j == null) return 0;
// first job is the one that has been waiting the longest JobTiming jt = j.getTiming();
long startAfter = j.getTiming().getStartAfter(); // PoisonJob timing is null, prevent NPE at shutdown
if (jt == null)
return 0;
long startAfter = jt.getStartAfter();
return _context.clock().now() - startAfter; return _context.clock().now() - startAfter;
} }