-
Notifications
You must be signed in to change notification settings - Fork 161
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: register data provider listener only if it has not been registered #11471
Conversation
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.
This looks good but I spent some time to understand why it's needed.
From the code I see paired handleDetach
method which do the clean up.
So assuming the expected workflow detach
should always happen after attach
and this check should not be needed at all.
The problem is in the method names which are uses in two cases:
- when the node is attached/detached (this is a normal expected workflow). And method names are fine for this situation.
- when data provider is set:
handleDetach
and thenhandleAttach
are called .
In the second case the method names are not suitable. Since the same methods are used in two totally different cases they should be renamed.
This is one thing which I would like to see changed here.
Another : it's still not obvious that setDataProvider
resets the listener in the same way as attach/detach does.
So even though the null
check is quite safe change I would like to see a unit test which will allow to prevent introducing such regression back.
That's because the PR doesn't contain any tests |
The conventional way of dealing with cases like this is to |
@Legioth , good point, I improved my solution. |
@TatuLund I'm going to add a test for this fix to move this important change forward, so if you currently are working on it also, please let me know :) |
@mshabarov Please do, I have not figured out good test yet. |
SonarQube analysis reported 2 issues
|
…ed (#11471) * fix: register data provider listener only if it has not been registered yet fixes: vaadin/flow-components#1914 Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com>
Hi @TatuLund and @denis-anisimov, when i performed cherry-pick to this commit to 2.7, i have encountered the following issue. Can you take a look and pick it manually? |
…ed (#11471) * fix: register data provider listener only if it has not been registered yet fixes: vaadin/flow-components#1914 Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com>
Hi @TatuLund and @denis-anisimov, when i performed cherry-pick to this commit to 2.6, i have encountered the following issue. Can you take a look and pick it manually? |
…ed (#11471) (#11546) * fix: register data provider listener only if it has not been registered yet fixes: vaadin/flow-components#1914 Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com> Co-authored-by: Tatu Lund <tatu@vaadin.com> Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com>
…ed (#11471) (#11547) * fix: register data provider listener only if it has not been registered yet fixes: vaadin/flow-components#1914 Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com> Co-authored-by: Tatu Lund <tatu@vaadin.com> Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com>
Removes the old data provider listener and adds a new one upon setting up a data provider and attaching a component to the page. Reorders and makes the 'rebuild' method for ListBox not to being called in attach handler method, because it leads to loosing the data in cache. Follows up the memory leak issue in Flow (vaadin/flow#11471) and fixes the regression in components caused by the change in Flow. Related-to #1914.
…ed (#11471) * fix: register data provider listener only if it has not been registered yet fixes: vaadin/flow-components#1914 Co-authored-by: Mikhail Shabarov <mikhail@vaadin.com> (cherry picked from commit 067f63f)
Removes the old data provider listener and adds a new one upon setting up a data provider and attaching a component to the page. Reorders and makes the 'rebuild' method for ListBox not to being called in attach handler method, because it leads to loosing the data in cache. Follows up the memory leak issue in Flow (vaadin/flow#11471) and fixes the regression in components caused by the change in Flow. Related-to #1914. (cherry picked from commit d47cce4)
…2012) Removes the old data provider listener and adds a new one upon setting up a data provider and attaching a component to the page. Reorders and makes the 'rebuild' method for ListBox not to being called in attach handler method, because it leads to loosing the data in cache. Follows up the memory leak issue in Flow (vaadin/flow#11471) and fixes the regression in components caused by the change in Flow. Related-to #1914. (cherry picked from commit d47cce4)
…2012) Removes the old data provider listener and adds a new one upon setting up a data provider and attaching a component to the page. Reorders and makes the 'rebuild' method for ListBox not to being called in attach handler method, because it leads to loosing the data in cache. Follows up the memory leak issue in Flow (vaadin/flow#11471) and fixes the regression in components caused by the change in Flow. Related-to #1914. (cherry picked from commit d47cce4)
This ticket/PR has been released with platform 22.0.0.alpha2 and is also targeting the upcoming stable 22.0.0 version. |
fixes: vaadin/flow-components#1914