Prevent possible null pointer in netconf-connector's keepalives
[controller.git] / opendaylight / md-sal / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / sal / KeepaliveSalFacade.java
index d302cacf7732ea5bd8d0ce5e2765908f6fea22ff..6c29f1d33846df7fb054bdb4eb945881e3d55278 100644 (file)
@@ -92,7 +92,9 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
      */
     private void resetKeepalive() {
         LOG.trace("{}: Resetting netconf keepalive timer", id);
-        currentKeepalive.cancel(false);
+        if(currentKeepalive != null) {
+            currentKeepalive.cancel(false);
+        }
         scheduleKeepalive();
     }
 
@@ -100,7 +102,9 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler<NetconfSess
      * Cancel current keepalive and also reset current deviceRpc
      */
     private void stopKeepalives() {
-        currentKeepalive.cancel(false);
+        if(currentKeepalive != null) {
+            currentKeepalive.cancel(false);
+        }
         currentDeviceRpc = null;
     }