Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException (Null Pointer->Crash):未判断服务端返回数据是否为空导致的应用崩溃 #32

Open
liyansong2018 opened this issue Sep 15, 2021 · 0 comments

Comments

@liyansong2018
Copy link

[scenario]
网络异常时,直接登录,触发崩溃

[Analysis]
没有对收到的http报文进行判空操作

Snipaste_2021-09-12_13-10-40

[Suggestions]

3

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)
@liyansong2018 liyansong2018 changed the title NullPointerException:未判断服务端返回数据是否为空导致的应用崩溃 NullPointerException (Null Pointer->Crash):未判断服务端返回数据是否为空导致的应用崩溃 Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant