diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java index 42ef8d299..96ce8c102 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java @@ -48,8 +48,11 @@ import org.slf4j.LoggerFactory; * @author Kai Kreuzer - switched to parameterized logging * @author Hilbrand Bouwkamp - Made protected fields private and added new methods to give access. * @author Markus Rathgeb - Use separate collections to improve performance + * @author Chris Jackson - Ensure managed provider is only unset by current provider * * @param type of the element + * @param type of the key + * @param

type of the provider */ @NonNullByDefault public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonNull K, @NonNull P extends Provider> @@ -530,7 +533,9 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN } protected void unsetManagedProvider(ManagedProvider provider) { - managedProvider = Optional.empty(); + if (managedProvider.equals(provider)) { + managedProvider = Optional.empty(); + } } /**