Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Double initialize
Double initialize [message #1760508] Thu, 27 April 2017 19:30 Go to next message
Tim Roberts is currently offline Tim RobertsFriend
Messages: 29
Registered: September 2016
Junior Member
Took me awhile to track down a really weird timing bug in a binding and just want to make sure that the situation I'm about to describe is what 'should' happen as opposed to a bug...

I have a binding that has a UPNP participant discovery process. If I have previously added the thing, the existing thing will have a 'thingUpdated' called on it when it's discovered again at startup.

Now the problem:
My existing item starts it's initialization process (via initialize()). The thing is 'discovered' again and thingUpdate is called. Let's say that thingUpdate is called BEFORE the existing initialize completes - then you'd have the following:
1) initialize() started
2) thingUpdate() called
2a) dispose called
2b) initialize called
3) original initialize() finishes (and goes online)
4) second initialize() finishes

So essentially I have TWO initialize()s running at the same time. (which, in my cases, causes issues because the first one finishes and goes online BEFORE the second one finishes - and that causes the second one various issues since the thing is online before it's done).

Now - is this an expected situation or bug?
Re: Double initialize [message #1760578 is a reply to message #1760508] Fri, 28 April 2017 15:04 Go to previous messageGo to next message
Henning Treu is currently offline Henning TreuFriend
Messages: 44
Registered: April 2017
Member
Hi Tim,

are you initialising your Thing in a separate thread? Does your ThingHandler create a background thread to do so? In this case you should clean up this thread when the dispose method is called. This way the first run of initialize will cleanly be disposed and the 2nd run can initialise your Thing correctly.

Cheers,
Henning
Re: Double initialize [message #1760584 is a reply to message #1760578] Fri, 28 April 2017 15:32 Go to previous messageGo to next message
Tim Roberts is currently offline Tim RobertsFriend
Messages: 29
Registered: September 2016
Junior Member
I didn't because the initialize was only about 100ms or so (that's why it was such a hard timing issue to track down). I'll probably switch over to an interruptible initializing thread however because of this...

One other note - I'm kinda surprised there is no status change when this happens. If the first initialize completes before the thingUpdated - it will be online for the dispose/initialize of the update. There will obviously be a small amount of time between the dispose and initialize where the binding is actually in a 'not-online' status (however brief)

[Updated on: Fri, 28 April 2017 15:34]

Report message to a moderator

Re: Double initialize [message #1760729 is a reply to message #1760584] Tue, 02 May 2017 12:48 Go to previous messageGo to next message
Simon Kaufmann is currently offline Simon KaufmannFriend
Messages: 51
Registered: January 2011
Member
Okay, this rather sounds like a bug in the framework then. Would you please open an issue here? You may reference this discussion here, of course, so you can keep the description brief. I will then have a look.

Regarding the Thing's status: This is due to the fact that this dispose()-initialize() sequence actually is not done by the framework. It's in fact behavior that your handler inherited. Have a look at BaseThingHandler.thingUpdated(...). You may override this method and set the Thing's status accordingly, if you like.
Re: Double initialize [message #1760734 is a reply to message #1760729] Tue, 02 May 2017 13:16 Go to previous messageGo to next message
Simon Kaufmann is currently offline Simon KaufmannFriend
Messages: 51
Registered: January 2011
Member
Nevermind, I already created the issue to track this bug: https://github.com/eclipse/smarthome/issues/3351
Re: Double initialize [message #1760925 is a reply to message #1760734] Thu, 04 May 2017 11:45 Go to previous message
Tim Roberts is currently offline Tim RobertsFriend
Messages: 29
Registered: September 2016
Junior Member
Thanks!
Previous Topic:New biding has errors
Next Topic:Rollershutter in Paper UI
Goto Forum:
  


Current Time: Wed Dec 04 19:50:21 GMT 2024

Powered by FUDForum. Page generated in 0.03461 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top