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 stale transition bug when using dispatchers. #356

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

Laimiux
Copy link
Collaborator

@Laimiux Laimiux commented Mar 15, 2024

Fixing a bug where DeferredTransition can hold to a stale transition property if a state change happens while event is waiting to be dispatched. Instead, we should rely on the mutable property that lives in ListenerImpl

@@ -11,11 +9,10 @@ import com.instacart.formula.Transition
*/
class DeferredTransition<Input, State, EventT> internal constructor(
private val listener: ListenerImpl<Input, State, EventT>,
private val transition: Transition<Input, State, EventT>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the primary issue where we could be holding a stale transition.

@Volatile internal var manager: FormulaManagerImpl<Input, State, *>? = null
@Volatile internal var snapshotImpl: SnapshotImpl<Input, State>? = null
@Volatile internal var executionType: Transition.ExecutionType? = null
@Volatile private var manager: FormulaManagerImpl<Input, State, *>? = null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making private and using setDependencies to update

@carrotkite
Copy link

JaCoCo Code Coverage 81.49% ✅

Class Covered Meta Status
com/instacart/formula/internal/SnapshotImpl 81% 0%
com/instacart/formula/internal/DeferredTransition 100% 0%
com/instacart/formula/internal/ListenerImpl 75% 0%

Generated by 🚫 Danger

@Laimiux Laimiux merged commit 66b58e1 into master Mar 15, 2024
3 checks passed
@Laimiux Laimiux deleted the laimonas/fix-potential-bug-with-stale-transition branch March 15, 2024 20:59
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.

3 participants