Madan Jampani
Committed by Gerrit Code Review

ONOS-1802: Added a null check for the returned term

Change-Id: Iacdd8d8f6ef15560bc81162dfefde431271b1204
......@@ -365,7 +365,7 @@ public class DeviceManager
MastershipTerm term = termService.getMastershipTerm(deviceId);
final NodeId myNodeId = clusterService.getLocalNode().id();
// TODO: Move this type of check inside device clock manager, etc.
if (myNodeId.equals(term.master())) {
if (term != null && myNodeId.equals(term.master())) {
log.info("Retry marking {} offline", deviceId);
deviceClockProviderService.setMastershipTerm(deviceId, term);
event = store.markOffline(deviceId);
......@@ -604,7 +604,7 @@ public class DeviceManager
if (myNodeId.equals(event.roleInfo().master())) {
// confirm latest info
MastershipTerm term = termService.getMastershipTerm(did);
final boolean iHaveControl = myNodeId.equals(term.master());
final boolean iHaveControl = term != null && myNodeId.equals(term.master());
if (iHaveControl) {
deviceClockProviderService.setMastershipTerm(did, term);
myNextRole = MASTER;
......
......@@ -859,7 +859,7 @@ public class GossipDeviceStore
log.debug("Temporarily requesting role for {} to remove", deviceId);
mastershipService.requestRoleFor(deviceId);
MastershipTerm term = termService.getMastershipTerm(deviceId);
if (myId.equals(term.master())) {
if (term != null && myId.equals(term.master())) {
master = myId;
}
}
......