Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

thingUpdated() gets called during initialize() #3351

Closed
sjsf opened this issue May 2, 2017 · 3 comments · Fixed by #3524
Closed

thingUpdated() gets called during initialize() #3351

sjsf opened this issue May 2, 2017 · 3 comments · Fixed by #3524

Comments

@sjsf
Copy link
Contributor

sjsf commented May 2, 2017

As observed in /~https://github.com/openhab/openhab2-addons/pull/2019#issuecomment-298440882 and https://www.eclipse.org/forums/index.php/t/1085852/ it seems that ThingHandler.thingUpdated() gets called while the handler is still in ThingHandler.initialize(). This puts the unnecessary burden of handling synchronization on bindings and is not intended.

@martinvw
Copy link
Contributor

martinvw commented May 24, 2017

Pitty, was no one yet able to make progress on this, it's blocking openhab/openhab2-addons#2019

Was it confirmed to happen, do we have any call traces where the calls actually come from, because the code I see in openhab/openhab2-addons#2019 does do an async initialization.

And the documentation (which can of course be incorrect or outdated) states that ThingHandler.thingUpdated is:

This method is only called, if the thing has been initialized (status ONLINE/OFFLINE).

So that actually means that it should not even be called before the async initialization was finished.

@martinvw
Copy link
Contributor

martinvw commented May 24, 2017

And the documentation (which can of course be incorrect or outdated) states that @@

There it starts, it was changed in #3088 ;-)

I think it might actually be really closely related to that change. @SJKA can you look along with me?

@sjsf
Copy link
Contributor Author

sjsf commented May 26, 2017

Yes, I think I know what the problem is here:

  1. There indeed was a conscious decision to also inform the handler about an update as soon as the initialize() method returned. The assumption is the even if the Thing is not yet in ONLINE/OFFLINE/UNKNOWN status, the ThingHandler still started doing something, hence also needs to be informed if something changed. You are right, the documentation needs to be updated. We missed that.

  2. There was another change in the ThingManager which made the initialize() be called asynchronously. As it seems, this broke the "protection" described above, so that thingUpdated() currently also can get called while the initialize() is still running. This is a bug and needs to be fixed somehow.

It's all a bit tricky, therefore I can't promise to fix it immediately, but I will have a look into this in the next couple of days.

sjsf pushed a commit to sjsf/smarthome that referenced this issue May 26, 2017
...by also using the lock.

fixes eclipse-archived#3351
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
sjsf pushed a commit to sjsf/smarthome that referenced this issue May 26, 2017
fixes eclipse-archived#3351
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
kaikreuzer pushed a commit that referenced this issue May 26, 2017
...by also using the lock.

fixes #3351
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
kaikreuzer pushed a commit that referenced this issue May 26, 2017
fixes #3351
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants