Set UNINITIALIZED -> HANDLER_MISSING_ERROR after enabling a Thing and handler is missing (#1243)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2019-11-28 15:55:59 +01:00 committed by Kai Kreuzer
parent c50766d7c3
commit 0046774eb6
2 changed files with 7 additions and 2 deletions

View File

@ -1057,7 +1057,7 @@ public class ThingManagerImpl
initializeHandler(thing);
} else {
logger.debug(
"Not registering a handler at this point. The thing types of bundle {} are not fully loaded yet.",
"Not registering a handler at this point. The thing types of bundle '{}' are not fully loaded yet.",
identifier);
}
} else {
@ -1214,6 +1214,11 @@ public class ThingManagerImpl
} else {
// No handler registered. Try to register handler and initialize the thing.
registerAndInitializeHandler(thing, findThingHandlerFactory(thing.getThingTypeUID()));
// Check if registration was successful
if (!hasBridge(thing) && !isHandlerRegistered(thing)) {
setThingStatus(thing,
buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_MISSING_ERROR));
}
}
} else {
if (!thing.isEnabled()) {

View File

@ -683,7 +683,7 @@ public class ThingManagerOSGiJavaTest extends JavaOSGiTest {
waitForAssert(() -> {
assertThat(storage.containsKey(THING_UID.getAsString()), is(false));
assertThat(thing.getStatus(), is(ThingStatus.UNINITIALIZED));
assertThat(thing.getStatusInfo().getStatusDetail(), is(ThingStatusDetail.DISABLED));
assertThat(thing.getStatusInfo().getStatusDetail(), is(ThingStatusDetail.HANDLER_MISSING_ERROR));
}, SafeCaller.DEFAULT_TIMEOUT - 100, 50);
}