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

Change-Id: I9f5ef22e1fa5105cd9c1ee0d0a0b15c98f5a1abf
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index 8281f4e..1a37be5 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -457,8 +457,9 @@
         if (isReachable && deviceService.isAvailable(deviceId) &&
                 mastershipService.isLocalMaster(deviceId)) {
             //if ports are not discovered, retry the discovery
+            AtomicInteger count = retriedPortDiscoveryMap.get(deviceId);
             if (deviceService.getPorts(deviceId).isEmpty() &&
-                    retriedPortDiscoveryMap.get(deviceId).getAndIncrement() < maxRetries) {
+                    count != null && count.getAndIncrement() < maxRetries) {
                 discoverPorts(deviceId);
             }
             updatePortStatistics(device);