From 843aacb8597f09036df19c9a51368f930faaf4fd Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 15 Nov 2018 17:54:57 -0500 Subject: [PATCH] Preventing a NullPointerException while handling a node disconnection --- .../graphenej/api/android/NetworkService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 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 1b8a44b..cb44c48 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 @@ -690,19 +690,21 @@ public class NetworkService extends Service { isLoggedIn = false; - // Marking the selected node as not connected - mSelectedNode.setConnected(false); + if(mSelectedNode != null){ + // Marking the selected node as not connected + mSelectedNode.setConnected(false); - // Updating the selected node's 'connected' status on the NodeLatencyVerifier instance - if(nodeLatencyVerifier != null) - nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); + // Updating the selected node's 'connected' status on the NodeLatencyVerifier instance + if(nodeLatencyVerifier != null) + nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); + } if(tryReconnection) { // Registering current status mCurrentId = 0; mApiIds.clear(); - if (removeSelectedNode) { + if (removeSelectedNode && mSelectedNode != null) { // Remove node from node provider so that it is not returned for following connections nodeProvider.removeNode(mSelectedNode);