Skip to content
Permalink
Browse files

Keep persisted disabled status when thing is removed (#6870)

* Keep persisted disabled status when thing is removed

The disabled status was not persisted after a restart since it was
removed on shutdown during the thing removal.
Now it will be persisted, but the disabled status of permanently deleted
disabled things will remain as orphan entry in the database.

Fixes #6840

Signed-off-by: Florian Stolte <fstolte@itemis.de>
  • Loading branch information...
FStolte authored and kaikreuzer committed Jan 30, 2019
1 parent 1f60913 commit 8ae91aec5df2ac1fed00512a227f1df9901bf6d4
@@ -913,7 +913,7 @@ public void testUpdateThing() throws Exception {
}

@Test
public void testStorageEntryRemovedOnThingRemoval() throws Exception {
public void testStorageEntryRetainedOnThingRemoval() throws Exception {
registerThingTypeProvider();

AtomicReference<ThingHandlerCallback> thingHandlerCallback = new AtomicReference<>();
@@ -981,8 +981,10 @@ public void testStorageEntryRemovedOnThingRemoval() throws Exception {
new Thread((Runnable) () -> managedThingProvider.remove(THING.getUID())).start();

waitForAssert(() -> {
assertThat(storage.containsKey(THING_UID.getAsString()), is(false));
assertThat(thingRegistry.get(THING.getUID()), is(equalTo(null)));
}, SafeCaller.DEFAULT_TIMEOUT - 100, 50);

assertThat(storage.containsKey(THING_UID.getAsString()), is(true));
}

private void assertThingStatus(Map<String, Object> propsThing, Map<String, Object> propsChannel, ThingStatus status,
@@ -484,7 +484,6 @@ public void thingRemoved(final Thing thing, ThingTrackerEvent thingTrackerEvent)
}
}

storage.remove(thing.getUID().getAsString());
this.things.remove(thing);
}

0 comments on commit 8ae91ae

Please sign in to comment.
You can’t perform that action at this time.