From 5ef4ebfca72ffe8f245ad09d66d2e7cba380c530 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Mon, 1 Oct 2018 23:58:03 -0500 Subject: [PATCH] Preventing a NullPointerException by checking the nodeLatencyVerifier reference first --- .../cy/agorise/graphenej/api/android/NetworkService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java index aad4458..7a1ba3a 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java @@ -331,7 +331,8 @@ public class NetworkService extends Service { mSelectedNode.setConnected(true); // Updating the selected node's 'connected' status on the NodeLatencyVerifier instance - nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); + if(nodeLatencyVerifier != null) + nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); // Notifying all listeners about the new connection status RxBus.getBusInstance().send(new ConnectionStatusUpdate(ConnectionStatusUpdate.CONNECTED, ApiAccess.API_NONE)); @@ -568,7 +569,8 @@ public class NetworkService extends Service { mSelectedNode.setConnected(false); // Updating the selected node's 'connected' status on the NodeLatencyVerifier instance - nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); + if(nodeLatencyVerifier != null) + nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); // We have currently no selected node @@ -612,7 +614,8 @@ public class NetworkService extends Service { mSelectedNode.setConnected(false); // Updating the selected node's 'connected' status on the NodeLatencyVerifier instance - nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); + if(nodeLatencyVerifier != null) + nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); // We have currently no selected node mSelectedNode = null;