summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2018-12-21 11:27:09 -0500
committerJoey Grover <joeygrover@gmail.com>2018-12-21 11:27:09 -0500
commit1b80ecd522953118abd15fc85c3a8936f10c21a5 (patch)
tree57a175e07057184caec5592efa50959f92d8268c
parent7d329a17dc95fe16df557827fead48cb4caa79a2 (diff)
downloadsdl_android-bugfix/issue_945.tar.gz
Fix potential NPE for transportType during writebugfix/issue_945
There is likely a race condition where the runnable can be mid or starting execution as the router service is disconnecting or already disconntected.
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index a6069c8e1..e7e3f0dd6 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -114,6 +114,7 @@ import com.smartdevicelink.transport.utl.ByteArrayMessageSpliter;
import com.smartdevicelink.transport.utl.TransportRecord;
import com.smartdevicelink.util.AndroidTools;
import com.smartdevicelink.util.BitConverter;
+import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.SdlAppInfo;
import static com.smartdevicelink.transport.TransportConstants.FOREGROUND_EXTRA;
@@ -504,6 +505,12 @@ public class SdlRouterService extends Service{
transportType = TransportType.USB;
} else if(service.tcpTransport != null && service.tcpTransport.isConnected()){
transportType = TransportType.TCP;
+ }else{
+ // This means no transport is connected. Likely the
+ // router service has already disconnected and this
+ // is now just executing.
+ DebugTool.logError("Can't send packet, no transport specified and none are connected.");
+ return;
}
//Log.d(TAG, "Transport type was null, so router set it to " + transportType.name());
if(transportType != null){