From cda3640be1590da60ecd3e1bd11a9899ca655416 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 4 Aug 2025 16:37:32 +0530 Subject: [PATCH] juniper-contrail: publish events only for the module (#11373) * juniper-contrail: publish events only for the module This plugin has an ActionEventInterceptor of its own and currently it intercepts all action events which is incorrect as all action events are already handled by com.cloud.event.ActionEventInterceptor. This PR limits publishing events on event bus by plugin's interceptor only in case the event is from the same module. Existing behaviour was causing warnings in Webhook service as event account was missing. 2025-07-31 19:18:59,391 WARN [o.a.c.m.w.WebhookServiceImpl] ... to any webhook as account ID is missing Signed-off-by: Abhishek Kumar --- .../network/contrail/management/EventUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/network-elements/juniper-contrail/src/main/java/org/apache/cloudstack/network/contrail/management/EventUtils.java b/plugins/network-elements/juniper-contrail/src/main/java/org/apache/cloudstack/network/contrail/management/EventUtils.java index d47bf6eceeb..338caca1fbe 100644 --- a/plugins/network-elements/juniper-contrail/src/main/java/org/apache/cloudstack/network/contrail/management/EventUtils.java +++ b/plugins/network-elements/juniper-contrail/src/main/java/org/apache/cloudstack/network/contrail/management/EventUtils.java @@ -48,6 +48,10 @@ public class EventUtils { private static EventDistributor eventDistributor; + private static final String MODULE_TOP_LEVEL_PACKAGE = + EventUtils.class.getPackage().getName().substring(0, + EventUtils.class.getPackage().getName().lastIndexOf('.')); + public EventUtils() { } @@ -143,6 +147,13 @@ public class EventUtils { @Override public void interceptComplete(Method method, Object target, Object event) { ActionEvent actionEvent = method.getAnnotation(ActionEvent.class); + boolean sameModule = false; + if (target != null && target.getClass().getPackage() != null) { + sameModule = target.getClass().getPackage().getName().startsWith(MODULE_TOP_LEVEL_PACKAGE); + } + if (!sameModule) { + return; + } if (actionEvent != null) { CallContext ctx = CallContext.current(); if (!actionEvent.create()) {