diff options
author | Joey Grover <joeygrover@gmail.com> | 2017-02-07 21:22:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-07 21:22:27 -0500 |
commit | 932f7bcbb2d01a61bed6b8b2c877abfcd9b90b74 (patch) | |
tree | 24ef345768231ea3e3e07e0d03612ab5f97cfde1 | |
parent | 5a5ad935e708f6160a77c61801e756284921cbc8 (diff) | |
parent | 0b63654c3d3a5becc349c85cd19669d1c4a628e9 (diff) | |
download | sdl_android-932f7bcbb2d01a61bed6b8b2c877abfcd9b90b74.tar.gz |
Merge pull request #400 from smartdevicelink/bugfix/issue_383
Fixing case where config.getService() returns null
-rw-r--r-- | sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java | 8 | ||||
-rw-r--r-- | sdl_android_tests/src/com/smartdevicelink/SdlConnection/SdlConnectionTest.java | 14 |
2 files changed, 17 insertions, 5 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java index 3c51b9e7e..7a91c8cee 100644 --- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java +++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java @@ -41,10 +41,10 @@ public class SdlConnection implements IProtocolListener, ITransportListener { // Thread safety locks
static Object TRANSPORT_REFERENCE_LOCK = new Object();
Object PROTOCOL_REFERENCE_LOCK = new Object();
- +
private Object SESSION_LOCK = new Object();
private CopyOnWriteArrayList<SdlSession> listenerList = new CopyOnWriteArrayList<SdlSession>();
- private static TransportType legacyTransportRequest = null; + private static TransportType legacyTransportRequest = null;
private final static int BUFF_READ_SIZE = 1000000;
protected static MultiplexTransportConfig cachedMultiConfig = null;
@@ -302,7 +302,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener { }
}
}
- void registerSession(SdlSession registerListener) throws SdlException { + void registerSession(SdlSession registerListener) throws SdlException {
boolean didAdd = listenerList.addIfAbsent(registerListener);
if (!this.getIsConnected()) {
this.startTransport();
@@ -527,7 +527,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener { MultiplexTransport multi = ((MultiplexTransport)_transport);
MultiplexTransportConfig config = multi.getConfig();
ComponentName tempCompName = SdlBroadcastReceiver.consumeQueuedRouterService();
- if(config.getService().equals(tempCompName)){ //If this is the same service that just connected that we are already looking at. Attempt to reconnect
+ if(config.getService() != null && config.getService().equals(tempCompName)){ //If this is the same service that just connected that we are already looking at. Attempt to reconnect
if(!multi.getIsConnected() && multi.isDisconnecting() ){ //If we aren't able to force a connection it means the
_transport = new MultiplexTransport(config,this);
try {
diff --git a/sdl_android_tests/src/com/smartdevicelink/SdlConnection/SdlConnectionTest.java b/sdl_android_tests/src/com/smartdevicelink/SdlConnection/SdlConnectionTest.java index cf921541a..90122905a 100644 --- a/sdl_android_tests/src/com/smartdevicelink/SdlConnection/SdlConnectionTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/SdlConnection/SdlConnectionTest.java @@ -50,8 +50,20 @@ public class SdlConnectionTest extends AndroidTestCase { assertEquals(TransportType.MULTIPLEX, connection.getCurrentTransportType()); - + + // Test for handling of null service + MultiplexTransportConfig null_service_config = new MultiplexTransportConfig(this.mContext,SdlUnitTestContants.TEST_APP_ID); + null_service_config.setService(null); + SdlConnectionTestClass null_service_connection = new SdlConnectionTestClass(null_service_config, null); + Exception exception = null; + try{ + null_service_connection.forceHardwareConnectEvent(TransportType.MULTIPLEX); + }catch(NullPointerException e){ + exception = e; + } + + assertNull(exception); // Failed, unhandled NPE } public void testMultiplexConstructor(){ |