From 1ac2e8978b98f72ab3b6fc18259f9b5d75d46bc2 Mon Sep 17 00:00:00 2001 From: Markus Rathgeb Date: Sun, 28 Apr 2019 16:19:07 +0200 Subject: [PATCH] automation: remove specific handling for CompositeModuleHandlerFactory (#764) The member variable "compositeFactory" that holds the "CompositeModuleHandlerFactory" instance is set in the activation method by calling the constructor of of "CompositeModuleHandlerFactory". This reference is destroyed and unset in the deactivate method. There exists DS managed multiple optional references to "ModuleHandlerFactory". The "add" logic does not touch the "compositeFactory" variable. The "remove" logic checks if the given service reference is a "CompositeModuleHandlerFactory" and unsets the "compositeFactory" member variable. If e.g. a module handler factory is injected that also implements the CompositeModuleHandlerFactory the CompositeModuleHandlerFactory created by the activate method is still be used. If that specific module handler factory is removed again, the variable "compositeFactory" is unset and there is NO CompositeModuleHandlerFactory present anymore. There are two options: * The instance created in the activate method should be used as long as no other one is injected. * The instance created in the activate method should be used all the time. The whole code base does not contain another specific implementation for CompositeModuleHandlerFactory, so there is no (at least in openHAB Core) change that a CompositeModuleHandlerFactory is injected. So instead of adding a non deterministic usage of "some" composite module handler factory (which will require a fix of the "set module handler factory method" and some others), let's drop the buggy code in the "remove module handler factory" and use the manually created composite module handler factory all the time. Signed-off-by: Markus Rathgeb --- .../org/openhab/core/automation/internal/RuleEngineImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java index 3e23ac91b..16f77be26 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java @@ -463,10 +463,6 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener moduleTypes = moduleHandlerFactory.getTypes(); removeMissingModuleTypes(moduleTypes);