openhab / openhab-android

openHAB client for Android
https://play.google.com/store/apps/details?id=org.openhab.habdroid
Eclipse Public License 2.0
599 stars 315 forks source link

KotlinNullPointerException in queryServerProperties() #1806

Open mueller-ma opened 4 years ago

mueller-ma commented 4 years ago
Fatal Exception: kotlin.KotlinNullPointerException
       at org.openhab.habdroid.ui.MainActivity.queryServerProperties(MainActivity.kt:511)
       at org.openhab.habdroid.ui.MainActivity.retryServerPropertyQuery(MainActivity.kt:486)
       at org.openhab.habdroid.ui.activity.ContentController$CommunicationFailureFragment.onClick(ContentController.kt:516)
       at android.view.View.performClick(View.java:7352)
       at android.widget.TextView.performClick(TextView.java:14177)
       at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
       at android.view.View.performClickInternal(View.java:7318)
       at android.view.View.access$3200(View.java:846)
       at android.view.View$PerformClick.run(View.java:27800)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7050)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

For some reason the CommunicationFailureFragment isn't replaced by a NoNetworkFragment when the connection is lost.

Environment data

Client

mueller-ma commented 4 years ago

Is it possible that the connection is set to null in onAvailableConnectionChanged() and at the same time the user clicks on the retry button, but before onAvailableConnectionChanged() replaces the fragment? Maybe propsUpdateHandle should be canceled in onAvailableConnectionChanged() and the cast Connection? to Connection should be moved to fetchFlags().