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

[lgwebos] Avoid thing updates when the thing handler is already disposed #7299

Merged
merged 2 commits into from
Apr 10, 2020

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Apr 5, 2020

Signed-off-by: Laurent Garnier lg.hc@free.fr

@lolodomo lolodomo requested a review from sprehn as a code owner April 5, 2020 11:43
@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Copy link
Contributor

@cpmeister cpmeister left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo lolodomo changed the title [lgwebos] Ignore messages when the thing handler is already disposed [lgwebos] Avoid thing updates when the thing handler is already disposed Apr 9, 2020
@lolodomo
Copy link
Contributor Author

lolodomo commented Apr 9, 2020

Ok, I just updated the PR, the problem is now handled by the thing handler.

@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@sprehn
Copy link
Contributor

sprehn commented Apr 10, 2020

still trying to understand the issue.

OH initializes the handler
the reconnect job starts
once the socket connection can be established binding sends "hello" message to TV
tv responds with hello response
binding calls config.storeProperties(map);
binding sends "register" message to TV
tv responds with register response
binding calls config.storeKey(key);

I agree that we could optimize both storeProperties and storeKey to only actually update if values changed. It may already solve the problem, as these values are only set once at the beginning.

storeKey today is already designed not to go through re-initialization. Is storeProperties the problem?

Or is the problem, that the the connection sequence continues running, while the binding disposes, calls disconnect and LGWebOSTVSocket is in state DISCONNECTED. If so, what we could do is to stop the sequence by putting entry conditions into the connection sequence of LGWebOSTVSocket::onMessage

// add additional state CONNECTING

switch (response.getType()) {
....
            case "hello":
               if (state != CONNECTING) {
                    logger.debug("Skipping resonse {}, not in CONNECTING state, state was {}", message, state);
                    break;
                }
....
                break;
            case "registered":
               if (state != REGISTERING) {
                    logger.debug("Skipping resonse {}, not in REGISTERING state, state was {}", message, state);
                    break;
                }
  ....
              break;
        }

@lolodomo
Copy link
Contributor Author

Or is the problem, that the the connection sequence continues running, while the binding disposes

Yes, you got it.

Your option looks good to me, it is more or less the same as my previous test "listener == null" but with a really cleaner solution.
If a new state CONNECTING is introducing, we just have to take care of it in the thing handler.
I will change the PR to use this way to implement the fix.

@lolodomo
Copy link
Contributor Author

@sprehn : please review this new version.

Copy link
Contributor

@sprehn sprehn left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo
Copy link
Contributor Author

@sprehn : just one question/detail: we stop reconnection job and start keep alive job when the state is changed to REGISTERING. Should we rather do it now when the state is changed to CONNECTING ?

@lolodomo
Copy link
Contributor Author

@cpmeister : can you start a new review please ? The PR was largely changed since your first approval.

@sprehn
Copy link
Contributor

sprehn commented Apr 10, 2020

@sprehn : just one question/detail: we stop reconnection job and start keep alive job when the state is changed to REGISTERING. Should we rather do it now when the state is changed to CONNECTING ?

Good point.

It is better to stopReconnectJob() in CONNECTING.
but startKeepAliveJob should actually move to REGISTERED.

… the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor Author

Change with jobs done

@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Copy link
Contributor

@cpmeister cpmeister left a comment

Choose a reason for hiding this comment

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

LGTM

@cpmeister
Copy link
Contributor

Manually approved sign-off

@cpmeister cpmeister merged commit 8a99893 into openhab:2.5.x Apr 10, 2020
@lolodomo lolodomo deleted the lgwebos_ignore_msg branch April 10, 2020 19:10
@cpmeister cpmeister added this to the 2.5.4 milestone Apr 11, 2020
@cpmeister cpmeister added the bug An unexpected problem or unintended behavior of an add-on label Apr 11, 2020
Hans-Reiner pushed a commit to Hans-Reiner/openhab2-addons that referenced this pull request Apr 11, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Hans-Reiner Hoffmann <hans-reiner.hoffmann@gmx.de>
yfre pushed a commit to yfre/openhab-addons that referenced this pull request Apr 27, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Eugen Freiter <freiter@gmx.de>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request May 29, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
LoungeFlyZ pushed a commit to LoungeFlyZ/openhab2-addons that referenced this pull request Jun 8, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
J-N-K pushed a commit to J-N-K/openhab-addons that referenced this pull request Jul 14, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Jul 26, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: CSchlipp <christian@schlipp.de>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
…sed (openhab#7299)

* [lgwebos] Avoid thing updates when the thing handler is already disposed
* Change of state trigger for stopping the reconection job and starting the keep alive job

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants