From 874b479a69922b75aa8b2f415648fce03af4cd76 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 2 Feb 2016 20:54:35 -0800 Subject: [PATCH] avoid NPE by dropping message after test --- .../src/org/eehouse/android/xw4/BTService.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java index 872784eb0..2ff5bcc8f 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -1231,14 +1231,18 @@ public class BTService extends XWService { public int sendViaBluetooth( byte[] buf, int gameID, CommsAddrRec addr ) { int nSent = -1; - String btAddr = getSafeAddr( addr ); - if ( null != btAddr && 0 < btAddr.length() ) { - m_sender.add( new BTQueueElem( BTCmd.MESG_SEND, buf, btAddr, - gameID ) ); - nSent = buf.length; + if ( null == m_sender ) { + DbgUtils.logf( "sendViaBluetooth(): no send thread" ); } else { - DbgUtils.logf( "sendViaBluetooth(): no addr for dev %s", - addr.bt_hostName ); + String btAddr = getSafeAddr( addr ); + if ( null != btAddr && 0 < btAddr.length() ) { + m_sender.add( new BTQueueElem( BTCmd.MESG_SEND, buf, btAddr, + gameID ) ); + nSent = buf.length; + } else { + DbgUtils.logf( "sendViaBluetooth(): no addr for dev %s", + addr.bt_hostName ); + } } return nSent; }