You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hello,
I am currently trying to get into jira plugin development.
My issue is that my EventListener for IssueEvent gets called twice with the same data, which makes things complicated for me.
The method onIssueEvent gets called twice:
@ExportAsService @Component @Named("IssueModificationListener") public class IssueModificationListener implements DisposableBean, InitializingBean, LifecycleAware { @ComponentImport private final ApplicationProperties applicationProperties; @ComponentImport private final EventPublisher eventPublisher; @ComponentImport private final LifecycleManager lifecycleManager; @Inject public IssueModificationListener(ApplicationProperties applicationProperties, EventPublisher eventPublisher, LifecycleManager lifecycleManager) { this.applicationProperties = applicationProperties; this.eventPublisher = eventPublisher; this.lifecycleManager = lifecycleManager; eventPublisher.register(this); } public void destroy() throws Exception { } public void afterPropertiesSet() throws Exception { eventPublisher.register(this); } public void onStart() { } @EventListener public void onIssueEvent(IssueEvent issueEvent) { Long eventTypeId = issueEvent.getEventTypeId(); Issue issue = issueEvent.getIssue(); if (eventTypeId.equals(EventType.ISSUE_COMMENTED_ID)) { System.out.println("Issue commented on"); } else if (eventTypeId.equals(EventType.ISSUE_COMMENT_EDITED_ID)) { System.out.println("Comment edited"); } else if (eventTypeId.equals(EventType.ISSUE_COMMENT_DELETED_ID)) { System.out.println("Comment deleted"); } } }
Resulting in the following output:
[INFO] [talledLocalContainer] Comment deleted [INFO] [talledLocalContainer] Comment deleted
Is there anything I can do to prevent this from happening?
The used jira version is 6.4.12
Thanks in advance!
Actually, I just see that eventPublisher.register(this) gets called twice, once in the constructor and in afterPropertiesSet... That might explain things.
try to remove these annotations
@ExportAsService @Component @Named("IssueModificationListener")
because it will register the class into the container several times and the method annotated with @EventListener will be fired twice or more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.