Committed by
Gerrit Code Review
ONOS-1802: Added a null check for the returned term
Change-Id: Iacdd8d8f6ef15560bc81162dfefde431271b1204
Showing
2 changed files
with
3 additions
and
3 deletions
| ... | @@ -365,7 +365,7 @@ public class DeviceManager | ... | @@ -365,7 +365,7 @@ public class DeviceManager |
| 365 | MastershipTerm term = termService.getMastershipTerm(deviceId); | 365 | MastershipTerm term = termService.getMastershipTerm(deviceId); |
| 366 | final NodeId myNodeId = clusterService.getLocalNode().id(); | 366 | final NodeId myNodeId = clusterService.getLocalNode().id(); |
| 367 | // TODO: Move this type of check inside device clock manager, etc. | 367 | // TODO: Move this type of check inside device clock manager, etc. |
| 368 | - if (myNodeId.equals(term.master())) { | 368 | + if (term != null && myNodeId.equals(term.master())) { |
| 369 | log.info("Retry marking {} offline", deviceId); | 369 | log.info("Retry marking {} offline", deviceId); |
| 370 | deviceClockProviderService.setMastershipTerm(deviceId, term); | 370 | deviceClockProviderService.setMastershipTerm(deviceId, term); |
| 371 | event = store.markOffline(deviceId); | 371 | event = store.markOffline(deviceId); |
| ... | @@ -604,7 +604,7 @@ public class DeviceManager | ... | @@ -604,7 +604,7 @@ public class DeviceManager |
| 604 | if (myNodeId.equals(event.roleInfo().master())) { | 604 | if (myNodeId.equals(event.roleInfo().master())) { |
| 605 | // confirm latest info | 605 | // confirm latest info |
| 606 | MastershipTerm term = termService.getMastershipTerm(did); | 606 | MastershipTerm term = termService.getMastershipTerm(did); |
| 607 | - final boolean iHaveControl = myNodeId.equals(term.master()); | 607 | + final boolean iHaveControl = term != null && myNodeId.equals(term.master()); |
| 608 | if (iHaveControl) { | 608 | if (iHaveControl) { |
| 609 | deviceClockProviderService.setMastershipTerm(did, term); | 609 | deviceClockProviderService.setMastershipTerm(did, term); |
| 610 | myNextRole = MASTER; | 610 | myNextRole = MASTER; | ... | ... |
| ... | @@ -859,7 +859,7 @@ public class GossipDeviceStore | ... | @@ -859,7 +859,7 @@ public class GossipDeviceStore |
| 859 | log.debug("Temporarily requesting role for {} to remove", deviceId); | 859 | log.debug("Temporarily requesting role for {} to remove", deviceId); |
| 860 | mastershipService.requestRoleFor(deviceId); | 860 | mastershipService.requestRoleFor(deviceId); |
| 861 | MastershipTerm term = termService.getMastershipTerm(deviceId); | 861 | MastershipTerm term = termService.getMastershipTerm(deviceId); |
| 862 | - if (myId.equals(term.master())) { | 862 | + if (term != null && myId.equals(term.master())) { |
| 863 | master = myId; | 863 | master = myId; |
| 864 | } | 864 | } |
| 865 | } | 865 | } | ... | ... |
-
Please register or login to post a comment