Fix null pointer exception which may happen if shutdown happened before lease have got

This commit is contained in:
Andrii Chuzhynov 2022-01-12 20:04:19 +01:00
parent fda91d9070
commit b98cea76d0

View file

@ -763,9 +763,12 @@ public class Scheduler implements Runnable {
// Stop accepting new leases. Once we do this we can be sure that // Stop accepting new leases. Once we do this we can be sure that
// no more leases will be acquired. // no more leases will be acquired.
// //
Collection<Lease> leases = Collections.emptyList();
if (leaseCoordinator != null) {
leaseCoordinator.stopLeaseTaker(); leaseCoordinator.stopLeaseTaker();
leases = leaseCoordinator.getAssignments();
}
Collection<Lease> leases = leaseCoordinator.getAssignments();
if (leases == null || leases.isEmpty()) { if (leases == null || leases.isEmpty()) {
// //
// If there are no leases notification is already completed, but we still need to shutdown the worker. // If there are no leases notification is already completed, but we still need to shutdown the worker.