[Java.Interop-Tests] Add CreatePeer_ReplaceableDoesNotReplace test #1323
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.
Context: 3043d89
Context: dotnet/android#9862
Context: dotnet/android#9862 (comment)
In dotnet/android#9862, there is an observed "race condition" around
Android.App.Application
subclass creation. Two instances ofAndroidApp
were created, one from the "normal" app startup:and another from an
androidx.work.WorkerFactory
:However, what was odd about this "race condition" was that the second instance created would reliably win!
Further investigation suggested that this was less of a "race condition" and more a bug in
AndroidRuntime
, wherein when "Replaceable" instances were created, an existing instance would always be replaced.Aside: JniManagedPeerStates.Replaceable is from 3043d89:
What we're observing in dotnet/android#9862 is that while the Replaceable instance is replaced, it's being replaced by another Replaceable instance! This feels bananas; yes, Replaceable should be replacable, but only by non-Replaceable instances.
Update
JniRuntimeJniValueManagerContract
to add a newCreatePeer_ReplaceableDoesNotReplace()
test to codify the desired semantic that Replaceable instances do not replace Replaceable instances.Surprisingly, this does not fail on java-interop! Apparently
ManagedValueManager.AddPeer()
bails early whenPeekPeer()
finds a value, whileAndroidRuntime.AddPeer()
does not bail early.