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

Avoid state mutation in a public method, add a warning #6618

Merged
merged 5 commits into from
Oct 4, 2019

Conversation

denis-anisimov
Copy link
Contributor

@denis-anisimov denis-anisimov commented Oct 4, 2019

Fixes #317


This change is Reviewable

Copy link
Contributor

@caalador caalador left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @denis-anisimov)


flow-server/src/main/java/com/vaadin/flow/internal/StateTree.java, line 421 at r1 (raw file):

    private Set<StateNode> doCollectDirtyNodes(boolean reset) {
        Set<StateNode> collectedNodes = dirtyNodes;
        dirtyNodes = new LinkedHashSet<>();

Dirty nodes is reset every time and never checks the flag.
Also on false the state should be returned as a copy.

Copy link
Contributor Author

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 3 files at r1.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @caalador)


flow-server/src/main/java/com/vaadin/flow/internal/StateTree.java, line 421 at r1 (raw file):

Previously, caalador wrote…

Dirty nodes is reset every time and never checks the flag.
Also on false the state should be returned as a copy.

Right, forgot to do everything.
Thanks.

@ujoni ujoni added the +0.0.1 label Oct 4, 2019
Copy link
Contributor

@caalador caalador left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 2 files at r2, 1 of 1 files at r3.
Reviewable status: :shipit: complete! all discussions resolved, 1 of 1 LGTMs obtained

@denis-anisimov denis-anisimov merged commit d04fbe5 into master Oct 4, 2019
@denis-anisimov denis-anisimov deleted the 317-collectDirtyNodes branch October 4, 2019 17:20
@joheriks joheriks added this to the 2.1.0.beta2 milestone Oct 7, 2019
ujoni pushed a commit that referenced this pull request Oct 11, 2019
ujoni pushed a commit that referenced this pull request Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad design of StateTree.collectDirtyNodes()
4 participants