[icalendar] Fix race condition while initialization of EventFilterHandler (#9230)
* [icalendar] Fix race condition while initialization of EventFilterHandler Should fix #9029. The channels do not get updated as the known channels by the binding where only updated if Bridge was already online while initializing EventFilterHandler. Also added a bit more output. * [icalendar] use implicit conversion to string for logging Signed-off-by: Michael Wodniok <michi@noorganization.org> Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>pull/9442/head
parent
05b7bbdccf
commit
de390b96be
|
@ -95,9 +95,7 @@ public class EventFilterHandler extends BaseThingHandler implements CalendarUpda
|
|||
@Override
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
if (command instanceof RefreshType) {
|
||||
if (initFinished) {
|
||||
updateStates();
|
||||
}
|
||||
updateStates();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,14 +119,13 @@ public class EventFilterHandler extends BaseThingHandler implements CalendarUpda
|
|||
}
|
||||
configuration = config;
|
||||
|
||||
updateChannelSet(config);
|
||||
initFinished = true;
|
||||
if (iCalendarBridge.getStatus() != ThingStatus.ONLINE) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
|
||||
return;
|
||||
} else {
|
||||
updateChannelSet(config);
|
||||
updateStates();
|
||||
}
|
||||
initFinished = true;
|
||||
updateStates();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,6 +254,10 @@ public class EventFilterHandler extends BaseThingHandler implements CalendarUpda
|
|||
* Updates all states and channels. Reschedules an update if no error occurs.
|
||||
*/
|
||||
private void updateStates() {
|
||||
if (!initFinished) {
|
||||
logger.debug("Ignoring call for updating states as this instance is not initialized yet.");
|
||||
return;
|
||||
}
|
||||
final Bridge iCalendarBridge = getBridge();
|
||||
if (iCalendarBridge == null) {
|
||||
logger.debug("Bridge not instantiated!");
|
||||
|
|
|
@ -183,6 +183,7 @@ public class ICalendarHandler extends BaseBridgeHandler implements CalendarUpdat
|
|||
ThingHandler handler = childThing.getHandler();
|
||||
if (handler instanceof CalendarUpdateListener) {
|
||||
try {
|
||||
logger.trace("Notifying {} about fresh calendar.", handler.getThing().getUID());
|
||||
((CalendarUpdateListener) handler).onCalendarUpdated();
|
||||
} catch (Exception e) {
|
||||
logger.trace("The update of a child handler failed. Ignoring.", e);
|
||||
|
|
Loading…
Reference in New Issue