check if a value in a map exists before dereference, avoid NPE

Change-Id: I9f5ef22e1fa5105cd9c1ee0d0a0b15c98f5a1abf
This commit is contained in:
David K. Bainbridge 2018-11-07 11:43:43 -08:00 committed by Andrea Campanella
parent a349da9d6b
commit e6a00f00bf

View File

@ -463,8 +463,9 @@ public class NetconfDeviceProvider extends AbstractProvider
if (isReachable && deviceService.isAvailable(deviceId) && if (isReachable && deviceService.isAvailable(deviceId) &&
mastershipService.isLocalMaster(deviceId)) { mastershipService.isLocalMaster(deviceId)) {
//if ports are not discovered, retry the discovery //if ports are not discovered, retry the discovery
AtomicInteger count = retriedPortDiscoveryMap.get(deviceId);
if (deviceService.getPorts(deviceId).isEmpty() && if (deviceService.getPorts(deviceId).isEmpty() &&
retriedPortDiscoveryMap.get(deviceId).getAndIncrement() < maxRetries) { count != null && count.getAndIncrement() < maxRetries) {
discoverPorts(deviceId); discoverPorts(deviceId);
} }
updatePortStatistics(device); updatePortStatistics(device);