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

fix: Prevent crash when sending a post while media is uploading #923

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

nikclayton
Copy link
Contributor

Previous code used filterIsInstance<Ok<UploadEvent.FinishedEvent>>().

This can fail at runtime with class cast exception because the type in Ok<...> is erased so filterIsInstance was accepting any Ok Result. Later attempts to operate on it as a .FinishedEvent generated the run time error.

Fix that by explicitly checking the type of the Ok result in first instead.

Previous code used `filterIsInstance<Ok<UploadEvent.FinishedEvent>>()`.

This can fail at runtime with class cast exception because the type in
`Ok<...>` is erased so `filterIsInstance` was accepting any `Ok`
`Result`. Later attempts to operate on it as a `.FinishedEvent`
generated the run time error.

Fix that by explicitly checking the type of the `Ok` result in `first`
instead.
@nikclayton nikclayton merged commit 69b87a3 into main Sep 3, 2024
22 checks passed
@nikclayton nikclayton deleted the upload-class-cast-exception branch September 3, 2024 11:05
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 this pull request may close these issues.

1 participant