How to get the current logged-in user in (for Jira version 7.0.10) ?

I need to modify (for Jira version 7.0.10) to NOT send out email if the current logged-in user is <some-userid>.

Here's the code snippet of :

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser;

private static final ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); 


 public void handleIssueEventBundle(final IssueEventBundle bundle) {
  if (currentUser == null) {
      log.error("Cannot determine current logged-in user");  // <<<<--------- this error shows up in the log
  if (currentUser.getUsername().equals(specialUser)) {
      log.debug("1. Ignore sending email notification because user=[" + currentUser.getUsername() + "]");



In the atlassian-jira.log, i see:

   [c.a.j.e.listeners.mail.MailListener] Cannot determine current logged-in user

What is the correct way to get the current logged-in user in ?



1 answer

1 accepted has a getUser() method that should tell you the info you want

 protected void handleDefaultIssueEvent(final IssueEvent event) {
        if (event.isRedundant()) {


Thanks.  I saw that method, but the debug messages i've put in indicate that handleIssueEventBundle() is STILL being invoked by Jira.  As far as i can tell, emails are getting sent out by handleIssueEventBundle().

The argument to handleIssueEventBundle is of type "IssueEventBundle".  I have not been able to get the appropriate code in place in order to convert IssueEventBundle to an IssueEvent.

Do you have any pointers on how to get an IssueEvent from within handleIssueEventBundle() method?

DefaultIssueEventBundle has a getEvents method that looks like it returns JiraIssueEvent objects which have a asIssueEvent method to access the original IssueEvent object

Matt, thanks again for your help.

I also saw that earlier in the docs and already tried:

public void handleIssueEventBundle(final IssueEventBundle bundle) {
   Collection<JiraIssueEvent> Cjie = bundle.getEvents();
       for (JiraIssueEvent jie: Cjie) {
            IssueEvent event = jie.asIssueEvent(); // <<--- compiler complains about asIssueEvent() being not found
            log.debug("user of current event object is [" + event.getUser().getName() + "]");


However, i got compilation errors:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jira-core: Compilation failure
[ERROR] /...../atlassian-jira-software-7.0.10-source/jira-project/jira-components/jira-core/src/main/java/com/atlassian/jira/event/listeners/mail/[147,35] cannot find symbol
[ERROR] symbol:   method asIssueEvent()
[ERROR] location: variable jie of type com.atlassian.jira.event.issue.JiraIssueEvent

Any other suggestions would be greatly appreciated.



Hmm. Cast jie to DelegatingJiraIssueEvent perhaps

Your suggestion worked!

Thanks for your help, Matt.




Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Jan 15, 2019 in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

292 views 5 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you