Incorrect JQL results via Java Api


We have run into an issue in our plugin where a correct jql search query returns no result.
This issue happens for several of our customers and unfortunately we can’t reproduce it in our test environment
Here is the code we’re using:

logger.debug("AdminUser: " + actorUser.getDisplayName() + "(" + actorUser.getKey() + ")");
issues = findIssuesFromJQL(actorUser, jql);

    public List<Issue> findIssuesFromJQL(ApplicationUser user, String jql) {
        try {
            Query query = new DefaultJqlQueryParser().parseQuery(jql);
            logger.debug("query: " + query.toString());
            /* Get JQL-result */
            SearchResults searchResults =, query, PagerFilter.getUnlimitedFilter());
            List<Issue> issues = searchResultsHelper.getResults(searchResults);
            logger.debug("JQL result size: " + issues.size());
            return issues;
        } catch (Exception ee) {
            logger.error("JQL is invalid: " + jql, ee);
        } finally {
        return new ArrayList<>();

public class SearchResultsHelper {
  private final BuildUtilsInfoImpl build = new BuildUtilsInfoImpl();

  private Method getMethod() {
    String method = build.getVersionNumbers()[0] < 8 ? "getIssues" : "getResults";
    try {
      return SearchResults.class.getMethod(method);
    } catch (NoSuchMethodException e) {
      throw new RuntimeException("Unable to find method: " + method + " in class: SearchResults", e);

  public List<Issue> getResults(SearchResults searchResults) {
    Method method = getMethod();

    try {
      return (List<Issue>) method.invoke(searchResults);
    } catch(IllegalAccessException | InvocationTargetException e) {
      throw new RuntimeException("Error in invoking method: " + method.getName() + " from class: SearchResults", e);

As far we can see from debug logs jql is valid and valid ApplicationUser is provided. But jql query returns zero results.
We tested similar query through Jira user interface and REST API - and the users get the right results.

This code is called from within our com.atlassian.scheduler.JobRunner implementation.

Every impacted customer upgraded from Jira 7.x to 8.4.1.


Are you sure that actorUser in this case has BROWSE permissions to the correct projects? It seems as though you should not be relying on a user-provided User object.

1 Like

Good question, yes this is something we have checked. We had the customer log in as this user (confirmed via logs) and browse to the test issue. We also confirmed that they were able to get the test issue via the REST api while authenticating as the mentioned user.

1 Like

Is the JQL query defined by users? Do they use 3rd party functions in that query?
It might be possible they’re using JQL functions that check permissions against authenticationContext instead of user that’s provided in search call (which isn’t correct, but it’s possible).

1 Like

Thanks for the suggestion. We’re having the customer test with the simplest of JQL

key = ABC-123

And are able to reproduce this issue.

What sort of context does this run in? Is this in a user-facing thread or as a Service or Event Handler?

We’re running this in a Scheduler / Job Runner context. We’re seeing the correct JQL and user being logged when this code runs.

Maybe a stupid question, but is it possible that when you invoke the method getResults() which returns List<T>, that it returns a list of objects that cannot be cast into Issues for some reason? Or is it returning an empty list of results as well?

You don’t need to call jiraThreadLocalUtil from scheduler job runners, I’m wondering if this might cause the issue.

We built a custom version without this, and it’s still not working in the client environment.

The page at Jira Service Management says they no longer answer dev questions, does anyone know if this is the case? We’re completely stuck here.

Did you also try setting logged in user in authentication context? There might be a bug in Jira somewhere, you never know.

1 Like

Hi @boris were you able to find a solution for this problem? We also have some customers experiencing this problem on their instances with our apps.

Hi @boris or @kubilay

There is a similar issue happening with our JIRA instance. We are currently on JIRA 8.5.4 (Data Center). Before this, we were on JIRA 7.3.8 (non DC …JIRA Server). We have a listener, that would on every event, take the current issue key and append it to a JQL Search query. So say for example it would be ‘issuekey = xxx and status = Open’ or ‘issuekey = xxxx and status = In Progress’. Although the issue is in the correct status (i.e. just moved to that status), the results returned are 0. The results returned are 0 on both 8.5.4. and 7.3.8.

Hence when were using 7.3.8, there was a reindex method that was put in (calls IssueIndexManager), in order to re-index the issue, and find the issue in the next part of the plugin. This all worked fine in 7.3.8 and 8.5.4 DC UAT instance which has a single node. But the same code on 8.5.4 DC live instance (multi node), throws exceptions on the issueIndexManager.release() method, sometimes.

Is there perhaps another way to reindex an issue on JIRA Data Center with multiple nodes, in order to get the most recent results returned?

Thanking you