Skip to content

Commit cda3640

Browse files
authored
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 <[email protected]>
1 parent 626f3de commit cda3640

File tree

1 file changed

+11
-0
lines changed
  • plugins/network-elements/juniper-contrail/src/main/java/org/apache/cloudstack/network/contrail/management

1 file changed

+11
-0
lines changed

plugins/network-elements/juniper-contrail/src/main/java/org/apache/cloudstack/network/contrail/management/EventUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public class EventUtils {
4848

4949
private static EventDistributor eventDistributor;
5050

51+
private static final String MODULE_TOP_LEVEL_PACKAGE =
52+
EventUtils.class.getPackage().getName().substring(0,
53+
EventUtils.class.getPackage().getName().lastIndexOf('.'));
54+
5155
public EventUtils() {
5256
}
5357

@@ -143,6 +147,13 @@ public Object interceptStart(Method method, Object target) {
143147
@Override
144148
public void interceptComplete(Method method, Object target, Object event) {
145149
ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
150+
boolean sameModule = false;
151+
if (target != null && target.getClass().getPackage() != null) {
152+
sameModule = target.getClass().getPackage().getName().startsWith(MODULE_TOP_LEVEL_PACKAGE);
153+
}
154+
if (!sameModule) {
155+
return;
156+
}
146157
if (actionEvent != null) {
147158
CallContext ctx = CallContext.current();
148159
if (!actionEvent.create()) {

0 commit comments

Comments
 (0)