This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 499
Fix class cast exception on pending tests (EXPOSUREAPP-4909) #2249
Merged
ralfgehrer
merged 9 commits into
release/1.12.x
from
fix/4909-class-cast-exception-on-pending-test
Feb 2, 2021
Merged
Fix class cast exception on pending tests (EXPOSUREAPP-4909) #2249
ralfgehrer
merged 9 commits into
release/1.12.x
from
fix/4909-class-cast-exception-on-pending-test
Feb 2, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No nulls and errors need to be `Throwable`
The expectation is that due to type erase, the filter will let any type of `RequestFailed` through anyways.
d4rken
added
bug
Something isn't working
maintainers
Tag pull requests created by maintainers
labels
Feb 1, 2021
ralfgehrer
approved these changes
Feb 1, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice catch.
true, | ||
::navigateToMainScreen | ||
) | ||
private val networkErrorDialog: DialogHelper.DialogInstance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these two error dialogs identical? There used to be the http code included in the web exception, but it is not there. Maybe the generic one is sufficient anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body is different
chiljamgossow
approved these changes
Feb 2, 2021
Kudos, SonarCloud Quality Gate passed! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
bug
Something isn't working
maintainers
Tag pull requests created by maintainers
prio
PRs to review first.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The viewmodel on the pending test has a livedata object to show errors to the user, the code looks like this:
The UI code consuming this calls:
The stacktrace shows a class cast exception at that point.
Stacktrace from Play Console
While I can't reproduce it, what I think happens is
filterIsInstance
can't filter based on the generics soNetworkRequestWrapper.RequestFailed<DeviceUIState, CwaWebexception>
becomes
NetworkRequestWrapper.RequestFailed<DeviceUIState, Throwable>
the compiler doesn't notice this during build time though (type erasure?).
When then an exception is thrown that is not a
CwaWebexception
we try to cast it to one anyways -> Crash 💣NetworkRequestWrapper
does not enforce any types for the generics both value and error are<out T, out U>
So I also thought that there might be a null exception being passed, but that was not the case, the crash on a null exception looks like this.
Stacktrace on crash due to null exception
to prevent any future issues there I've adjusted the wrapper class to have stronger typing, i.e.:
NetworkRequestWrapper<out T : Any, out U : Any>
to prevent null arguments,and
RequestFailed<T : Any, U : Throwable>
to enforce that the second, error parameter is actually aThrowable
.Testing
deviceForTestersRelease