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

java.lang.NullPointerException in some cases #177

Closed
Marukohe opened this issue Aug 30, 2023 · 1 comment · Fixed by #179
Closed

java.lang.NullPointerException in some cases #177

Marukohe opened this issue Aug 30, 2023 · 1 comment · Fixed by #179
Assignees

Comments

@Marukohe
Copy link

Hello, I find in some cases, the app will crash because of NPE problem.
Here is the stack trace:

Caused by: java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:220)
	at java.util.Arrays$ArrayList.<init>(Arrays.java:4248)
	at java.util.Arrays.asList(Arrays.java:4235)
	at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:165)
	at com.secuso.privacyfriendlycodescanner.qrscanner.ui.activities.generator.QrGeneratorDisplayActivity.newErrorCorrectionAdapter(QrGeneratorDisplayActivity.java:179)
	at com.secuso.privacyfriendlycodescanner.qrscanner.ui.activities.generator.QrGeneratorDisplayActivity.onResume(QrGeneratorDisplayActivity.java:232)
	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1531)
	at android.app.Activity.performResume(Activity.java:8422)
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4793)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4836) 
	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54) 
	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) 
	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308) 
	at android.os.Handler.dispatchMessage(Handler.java:106) 
	at android.os.Looper.loopOnce(Looper.java:201) 
	at android.os.Looper.loop(Looper.java:288) 
	at android.app.ActivityThread.main(ActivityThread.java:7898) 
	at java.lang.reflect.Method.invoke(Native Method) 
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

After reading the soure code, I may find the reason. When QrGeneratorDisplayActivity#onResume, QrGeneratorDisplayActivity#newErrorCorrectionAdapter will be invoked. The parameter currentErrorCorrections in some cases will be assigned to null in QrGeneratorDisplayActivity#updateDropDownMenus. So a NPE happens in some cases.

Here is a video which can trigger the crash.

codescanner.mp4

Device : Google pixel 4
OS: Android 12.

@udenr
Copy link
Collaborator

udenr commented Aug 31, 2023

Thanks for the detailed description and the video. I will have a look at it.

@udenr udenr self-assigned this Aug 31, 2023
udenr added a commit that referenced this issue Aug 31, 2023
@udenr udenr linked a pull request Aug 31, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants