HubbellCorp/SweetBlue

NullPointerException in P_ConnectionFailManager.onConnectionFailed()

mkarhumaa opened this issue · 0 comments

Hello,

We have seen following NullPointerException happening every now and then on the field. Based on my understanding this could happen when user turns of Bluetooth at certain state.

Looking at the implementation, only reason I can think of how this could happen is that there would be a race condition where m_timeOfFirstConnect is set to null from another thread right before the Interval.delta(m_timeOfFirstConnect, currentTime); call.

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
       at com.idevicesinc.sweetblue.internal.P_ConnectionFailManager.onConnectionFailed(P_ConnectionFailManager.java:141)
       at com.idevicesinc.sweetblue.internal.P_DeviceConnectionManager.disconnectWithReason(P_DeviceConnectionManager.java:621)
       at com.idevicesinc.sweetblue.internal.P_BleDeviceImpl.disconnectWithReason(P_BleDeviceImpl.java:2324)
       at com.idevicesinc.sweetblue.internal.P_DeviceManager.disconnectAllForTurnOff(P_DeviceManager.java:527)
       at com.idevicesinc.sweetblue.internal.P_BleManager_ListenerProcessor.handleBleTurningOff(P_BleManager_ListenerProcessor.java:604)
       at com.idevicesinc.sweetblue.internal.P_BleManager_ListenerProcessor.onNativeBleStateChange(P_BleManager_ListenerProcessor.java:550)
       at com.idevicesinc.sweetblue.internal.P_BleManager_ListenerProcessor.onNativeBleStateChangeFromBroadcastReceiver(P_BleManager_ListenerProcessor.java:346)
       at com.idevicesinc.sweetblue.internal.P_BleManager_ListenerProcessor$BluetoothReceiver.onReceive(P_BleManager_ListenerProcessor.java:801)
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$android-app-LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1918)
       at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(LoadedApk.java:2)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8741)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Unfortunately I don't know how to reproduce this npe.