NullPointerException (Null Pointer->Crash):未判断服务端返回数据是否为空导致的应用崩溃 #32
Open
Description
[scenario]
网络异常时,直接登录,触发崩溃
[Analysis]
没有对收到的http报文进行判空操作
[Suggestions]
199行代码之后,判断 loginUrl
是否为空,如果空,则弹窗或者直接报错,不进行后续的登录流程
[Log]
beyond1q:/data/system/dropbox # cat data_app_crash@1631422710856.txt
Process: me.yluo.ruisiapp
Flags: 0x28c8be44
Package: me.yluo.ruisiapp v40 (2.9.8.2)
Foreground: Yes
Build: samsung/dream2qltezh/dream2qltechn:7.1/N2G48H/G9550ZHU1AQEE:user/release-keys
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null
object reference
at me.yluo.ruisiapp.myhttp.HttpUtil.getUrl(HttpUtil.java:18)
at me.yluo.ruisiapp.myhttp.HttpUtil.post(HttpUtil.java:40)
at me.yluo.ruisiapp.activity.LoginActivity.startLogin(LoginActivity.java:255)
at me.yluo.ruisiapp.activity.LoginActivity.lambda$onCreate$0$LoginActivity(LoginActivity.java:100)
at me.yluo.ruisiapp.activity.-$$Lambda$LoginActivity$x9wErgAks3boUA8rdIy9PIUWvTQ.onClick(lambda)
at android.view.View.performClick(View.java:5638)
at android.view.View$PerformClick.run(View.java:22430)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6198)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
Metadata
Assignees
Labels
No labels