Fix: resolve a NPE caused by configmap watcher

1. lower down the watcher onClose exception log
2. correct watcher documents of service and configmap

Change-Id: I85cedf5ec5e0939b64bea6716221eed58349ace6
(cherry picked from commit c9e29247c0e226f63b25c1ca6eb5a777f2cc1433)
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubernetesServiceWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubernetesServiceWatcher.java
index d6af10f..5aa1e4f 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubernetesServiceWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubernetesServiceWatcher.java
@@ -246,10 +246,10 @@
 
         @Override
         public void onClose(WatcherException e) {
-            // due to the bugs in fabric8, pod watcher might be closed,
-            // we will re-instantiate the pod watcher in this case
+            // due to the bugs in fabric8, service watcher might be closed,
+            // we will re-instantiate the service watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Service watcher OnClose, re-instantiate the POD watcher...");
+            log.info("Service watcher OnClose, re-instantiate the Service watcher...");
             instantiateWatcher();
         }
 
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtFloatingIpWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtFloatingIpWatcher.java
index d15a515..fca541e 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtFloatingIpWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtFloatingIpWatcher.java
@@ -194,7 +194,11 @@
 
         @Override
         public void onClose(WatcherException e) {
-
+            // due to the bugs in fabric8, the watcher might be closed,
+            // we will re-instantiate the watcher in this case
+            // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
+            log.info("The floating IP watcher OnClose, re-instantiate the watcher...");
+            instantiateWatcher();
         }
 
         private void processAddition(String resource) {
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtLoadBalancerWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtLoadBalancerWatcher.java
index 5b0dd75..77d31a7 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtLoadBalancerWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtLoadBalancerWatcher.java
@@ -198,7 +198,7 @@
             // due to the bugs in fabric8, the watcher might be closed,
             // we will re-instantiate the watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Load Balancer watcher OnClose, re-instantiate the watcher...");
+            log.info("Load Balancer watcher OnClose, re-instantiate the watcher...");
 
             instantiateWatcher();
         }
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtPodWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtPodWatcher.java
index e92808d..4120dcb 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtPodWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtPodWatcher.java
@@ -164,7 +164,7 @@
             // due to the bugs in fabric8, pod watcher might be closed,
             // we will re-instantiate the pod watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Pod watcher OnClose, re-instantiate the POD watcher...");
+            log.info("Pod watcher OnClose, re-instantiate the POD watcher...");
             instantiatePodWatcher();
         }
 
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRouterWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRouterWatcher.java
index 58ca9f8..13bce6b 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRouterWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRouterWatcher.java
@@ -211,7 +211,7 @@
             // due to the bugs in fabric8, the watcher might be closed,
             // we will re-instantiate the watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Virtual Router watcher OnClose, re-instantiate the watcher...");
+            log.info("Virtual Router watcher OnClose, re-instantiate the watcher...");
 
             instantiateWatcher();
         }
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupWatcher.java
index 5a25db3..da4656b 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupWatcher.java
@@ -233,7 +233,7 @@
             // due to the bugs in fabric8, the watcher might be closed,
             // we will re-instantiate the watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Security Group watcher OnClose, re-instantiate the watcher...");
+            log.info("Security Group watcher OnClose, re-instantiate the watcher...");
 
             instantiateSgWatcher();
         }
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmWatcher.java
index 10328ee..79f59be 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmWatcher.java
@@ -216,7 +216,10 @@
 
         @Override
         public void onClose(WatcherException e) {
-            log.warn("VM watcher OnClose, re-instantiate the VM watcher...");
+            // due to the bugs in fabric8, the watcher might be closed,
+            // we will re-instantiate the watcher in this case
+            // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
+            log.info("VM watcher OnClose, re-instantiate the VM watcher...");
             instantiateWatcher();
         }
 
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmiWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmiWatcher.java
index 4e1121a..53814a6 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmiWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtVmiWatcher.java
@@ -190,7 +190,10 @@
 
         @Override
         public void onClose(WatcherException e) {
-            log.warn("VM watcher OnClose, re-instantiate the VM watcher...");
+            // due to the bugs in fabric8, the watcher might be closed,
+            // we will re-instantiate the watcher in this case
+            // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
+            log.info("VMI watcher OnClose, re-instantiate the VMI watcher...");
             instantiateWatcher();
         }
 
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java
index 3ef16f4..3a3ad12 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/NetworkAttachmentDefinitionWatcher.java
@@ -183,7 +183,7 @@
             // due to the bugs in fabric8, the watcher might be closed,
             // we will re-instantiate the watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Network-attachment-definition watcher OnClose, re-instantiate the watcher...");
+            log.info("Network-attachment-definition watcher OnClose, re-instantiate the watcher...");
 
             instantiateWatcher();
         }
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubernetesConfigMapWatcher.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubernetesConfigMapWatcher.java
index bac5e03..ff42589 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubernetesConfigMapWatcher.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubernetesConfigMapWatcher.java
@@ -165,10 +165,10 @@
 
         @Override
         public void onClose(WatcherException e) {
-            // due to the bugs in fabric8, pod watcher might be closed,
-            // we will re-instantiate the pod watcher in this case
+            // due to the bugs in fabric8, configmap watcher might be closed,
+            // we will re-instantiate the configmap watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Configmap watcher OnClose, re-instantiate the POD watcher...");
+            log.info("Configmap watcher OnClose, re-instantiate the configmap watcher...");
             instantiateWatcher();
         }
 
@@ -217,7 +217,9 @@
         }
 
         private KubernetesExternalLbConfig parseKubernetesExternalLbConfig(ConfigMap configMap, String configName) {
-            if (configMap.getData().get(GATEWAY_IP) == null || configMap.getData().get(RANGE_GLOBAL) == null) {
+
+            if (configMap == null || configMap.getData() == null ||
+                    configMap.getData().get(GATEWAY_IP) == null || configMap.getData().get(RANGE_GLOBAL) == null) {
                 return null;
             }
 
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeWatcher.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeWatcher.java
index 3949d79..c3cc427 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeWatcher.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/KubevirtNodeWatcher.java
@@ -176,7 +176,7 @@
             // due to the bugs in fabric8, node watcher might be closed,
             // we will re-instantiate the node watcher in this case
             // FIXME: https://github.com/fabric8io/kubernetes-client/issues/2135
-            log.warn("Node watcher OnClose, re-instantiate the node watcher...");
+            log.info("Node watcher OnClose, re-instantiate the node watcher...");
             instantiateNodeWatcher();
         }