summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Kirk <askirk@umich.edu>2017-02-09 14:12:28 -0500
committerAustin Kirk <askirk@umich.edu>2017-02-09 14:12:28 -0500
commit125b7176fb26893b51a385e617ba2203a272776f (patch)
treeca95440fc51adee757f21895640d554b2a0255e8
parent8487150d5f87630c3a0d3700dc0c644d7442308c (diff)
downloadsdl_android-bugfix/issue_387.tar.gz
Seperate catch for NPEbugfix/issue_387
Not sure if we want to make a function for the duplicated code from L108-112
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java b/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java
index f3ccb43c4..5a4cfda05 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java
@@ -1,10 +1,5 @@
package com.smartdevicelink.transport;
-import java.lang.ref.WeakReference;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
@@ -27,6 +22,11 @@ import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.transport.utl.ByteAraryMessageAssembler;
import com.smartdevicelink.transport.utl.ByteArrayMessageSpliter;
+import java.lang.ref.WeakReference;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
public class TransportBroker {
@@ -91,11 +91,11 @@ public class TransportBroker {
try {
routerServiceMessenger.send(message);
return true;
- } catch (RemoteException|NullPointerException e) { // NPE is STRICTLY for case that routerServiceMessenger is null
+ } catch (RemoteException e) {
e.printStackTrace();
//Let's check to see if we should retry
- if(!(e instanceof NullPointerException) && (e instanceof TransactionTooLargeException
- || (retryCount<5 && routerServiceMessenger.getBinder().isBinderAlive() && routerServiceMessenger.getBinder().pingBinder()))){ //We probably just failed on a small transaction =\
+ if(e instanceof TransactionTooLargeException
+ || (retryCount<5 && routerServiceMessenger.getBinder().isBinderAlive() && routerServiceMessenger.getBinder().pingBinder())){ //We probably just failed on a small transaction =\
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
@@ -103,7 +103,7 @@ public class TransportBroker {
}
return sendMessageToRouterService(message, retryCount++);
}else{
- //DeadObject or routerServiceMessenger is null, time to kill our connection
+ //DeadObject, time to kill our connection
Log.d(TAG, "Dead object while attempting to send packet");
routerServiceMessenger = null;
registeredWithRouterService = false;
@@ -111,7 +111,14 @@ public class TransportBroker {
onHardwareDisconnected(null);
return false;
}
- }
+ } catch (NullPointerException e){
+ Log.d(TAG, "Null messenger while attempting to send packet"); // NPE, routerServiceMessenger is null
+ routerServiceMessenger = null;
+ registeredWithRouterService = false;
+ isBound = false;
+ onHardwareDisconnected(null);
+ return false;
+ }
}else{
Log.e(TAG, "Unable to send message to router service. Not registered.");
return false;