Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 39cc052188e05e3b6b32d22edec0cfe0cab1d6fe
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Feb 03 16:39:37 2022
Ensure moving Lifecycle down from INITIALIZED throws
We should always throw an IllegalStateException when the
LifecycleRegistry state attempts to move from INITIALIZED to DESTROYED.
We currently only do this if there is an observer attached to the
registry.
RelNote: "Attemping to move the `Lifecycle.State` from `INITIALIZED` to
`DESTROYED` will now always throw an `IllegalStateException` regardless
of whether the `Lifecycle` has an attached observer."
Test: LifecycleRegistryTest
Bug: 177924329
Change-Id: I7c3903602cc4b9be234a0bed6e6392e710ce3206
M lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/WithLifecycleStateTest.kt
M lifecycle/integration-tests/kotlintestapp/src/test-common/java/androidx.lifecycle/LifecycleCoroutineScopeTestBase.kt
M lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
M lifecycle/lifecycle-livedata-core/src/test/java/androidx/lifecycle/LiveDataTest.java
M activity/activity/src/androidTest/java/androidx/activity/OnBackPressedDispatcherTest.kt
M lifecycle/lifecycle-runtime/src/test/java/androidx/lifecycle/LifecycleRegistryTest.java
M lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FlowWithLifecycleTest.kt
M lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/RepeatOnLifecycleTest.kt
https://android-review.googlesource.com/1972163
Branch: androidx-main
commit 39cc052188e05e3b6b32d22edec0cfe0cab1d6fe
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Feb 03 16:39:37 2022
Ensure moving Lifecycle down from INITIALIZED throws
We should always throw an IllegalStateException when the
LifecycleRegistry state attempts to move from INITIALIZED to DESTROYED.
We currently only do this if there is an observer attached to the
registry.
RelNote: "Attemping to move the `Lifecycle.State` from `INITIALIZED` to
`DESTROYED` will now always throw an `IllegalStateException` regardless
of whether the `Lifecycle` has an attached observer."
Test: LifecycleRegistryTest
Bug: 177924329
Change-Id: I7c3903602cc4b9be234a0bed6e6392e710ce3206
M lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/WithLifecycleStateTest.kt
M lifecycle/integration-tests/kotlintestapp/src/test-common/java/androidx.lifecycle/LifecycleCoroutineScopeTestBase.kt
M lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
M lifecycle/lifecycle-livedata-core/src/test/java/androidx/lifecycle/LiveDataTest.java
M activity/activity/src/androidTest/java/androidx/activity/OnBackPressedDispatcherTest.kt
M lifecycle/lifecycle-runtime/src/test/java/androidx/lifecycle/LifecycleRegistryTest.java
M lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FlowWithLifecycleTest.kt
M lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/RepeatOnLifecycleTest.kt
il...@google.com <il...@google.com> #3
This has been fixed internally and will be available in Lifecycle 2.5.0-alpha03.
ad...@gmail.com <ad...@gmail.com> #4
Hi
l....@gmail.com <l....@gmail.com> #5
It took almost 4 months to go from 2.4.0-alpha03 to 2.4.0 stable. Is there any way this could be backported to 2.4.2 so we don't have to wait couple of months for the fix? Context: afaiu this is blocking our update to Navigation 2.4.1
il...@google.com <il...@google.com> #6
Re
There's no way that throwing more often will unblock any update to Navigation you have in progress. Navigation 2.4.1 is compatible with Lifecycle 2.4 and 2.5.
Description
If you add an observers to a
Lifecycle
object and attempt to move thatLifecycle.State
fromINITIALIZED
toDESTROYED
, the following error will be thrown:If there is no observer, then the lifecycle state is moved without any error.
Moving the Lifecycle.State from
INITIALIZED
toDESTROYED
should be consistent whether or not there is an observer on the Lifecycle.