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

NPE in ByteArrayParcel init #2

Closed
tadfisher opened this issue Sep 3, 2022 · 2 comments
Closed

NPE in ByteArrayParcel init #2

tadfisher opened this issue Sep 3, 2022 · 2 comments

Comments

@tadfisher
Copy link

The init block in ByteArrayParcel throws an NPE because data is not set when setDataFromByteArray runs.

I'm not sure if this is caused by a compiler change in Kotlin 1.7, because ordinarily you'd get a compiler diagnostic like "data is not initialized".

The easiest fix would be to move the init { } block below where the data property is initialized.

Stacktrace:

Cannot invoke "java.util.List.clear()" because "this.data" is null
java.lang.NullPointerException: Cannot invoke "java.util.List.clear()" because "this.data" is null
	at com.chrynan.parcelable.core.ByteArrayParcel.setDataFromByteArray(ByteArrayParcel.kt:188)
	at com.chrynan.parcelable.core.ByteArrayParcel.<init>(ByteArrayParcel.kt:17)
	at com.chrynan.parcelable.core.ByteArrayParcel.<init>(ByteArrayParcel.kt:14)
	at com.chrynan.parcelable.core.JvmParcelKt.Parcel(JvmParcel.kt:3)
@github-actions
Copy link

github-actions bot commented Sep 3, 2022

Welcome and thanks for contributing! Make sure to leave a detailed explanation of the issue.

@chRyNaN
Copy link
Owner

chRyNaN commented Sep 12, 2022

@tadfisher Thanks for reporting this issue! This should be fixed in the latest version: https://github.com/chRyNaN/serialization-parcelable/releases/tag/0.5.0

@chRyNaN chRyNaN closed this as completed Sep 12, 2022
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

2 participants