diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java index 40c25278bc3..b4eff6197e8 100644 --- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java +++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ThingActionsResource.java @@ -120,13 +120,14 @@ public void addThingActions(ThingActions thingActions) { String scope = getScope(thingActions); if (handler != null && scope != null) { ThingUID thingUID = handler.getThing().getUID(); - Method[] methods = thingActions.getClass().getDeclaredMethods(); + Class clazz = thingActions.getClass(); + Method[] methods = clazz.getDeclaredMethods(); List actionUIDs = new ArrayList<>(); for (Method method : methods) { if (!method.isAnnotationPresent(RuleAction.class)) { continue; } - actionUIDs.add(annotationActionModuleTypeHelper.getModuleIdFromMethod(scope, method)); + actionUIDs.add(annotationActionModuleTypeHelper.getModuleIdFromClassAndMethod(scope, clazz, method)); } if (actionUIDs.isEmpty()) { return; diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java index bc9919176a3..bcd31df57ce 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/module/provider/AnnotationActionModuleTypeHelper.java @@ -100,7 +100,7 @@ public Collection parseAnnotations(String name, Object action List outputs = getOutputsFromAction(method); RuleAction ruleAction = method.getAnnotation(RuleAction.class); - String uid = getModuleIdFromMethod(name, method); + String uid = getModuleIdFromClassAndMethod(name, clazz, method); Set tags = new HashSet<>(Arrays.asList(ruleAction.tags())); ModuleInformation mi = new ModuleInformation(uid, actionProvider, method); @@ -117,7 +117,7 @@ public Collection parseAnnotations(String name, Object action return moduleInformation; } - public String getModuleIdFromMethod(String actionScope, Method method) { + public String getModuleIdFromClassAndMethod(String actionScope, Class clazz, Method method) { String uid = actionScope + "." + method.getName() + "#"; MessageDigest md5 = null; try { @@ -125,6 +125,7 @@ public String getModuleIdFromMethod(String actionScope, Method method) { } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } + md5.update(clazz.getName().getBytes()); for (Class parameter : method.getParameterTypes()) { md5.update(parameter.getName().getBytes()); } diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java index fa9e9f93075..db3dcd5d293 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java @@ -67,7 +67,9 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest { } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } - for (Class parameter : TestActionProvider.class.getDeclaredMethods()[0].getParameterTypes()) { + Class clazz = AnnotationActionModuleTypeProviderTest.TestActionProvider.class; + md5.update(clazz.getName().getBytes()); + for (Class parameter : clazz.getDeclaredMethods()[0].getParameterTypes()) { md5.update(parameter.getName().getBytes()); } TEST_ACTION_SIGNATURE_HASH = String.format("%032x", new BigInteger(1, md5.digest())); diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java index f03dcfb5918..59f3e1870fd 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/thingsupport/AnnotatedThingActionModuleTypeProviderTest.java @@ -71,8 +71,9 @@ public class AnnotatedThingActionModuleTypeProviderTest extends JavaTest { } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } - for (Class parameter : AnnotatedThingActionModuleTypeProviderTest.TestThingActionProvider.class - .getDeclaredMethods()[0].getParameterTypes()) { + Class clazz = AnnotatedThingActionModuleTypeProviderTest.TestThingActionProvider.class; + md5.update(clazz.getName().getBytes()); + for (Class parameter : clazz.getDeclaredMethods()[0].getParameterTypes()) { md5.update(parameter.getName().getBytes()); } TEST_ACTION_SIGNATURE_HASH = String.format("%032x", new BigInteger(1, md5.digest()));