Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner fails to implement Liskov principle?

Because issuePicker custom field is not parseable (does not support IN or IN (subquery) ) by search I'm trying to implement own JQL search plugin to run something like this:


project = MYPROJECT and issuetype = Epic and issueFunction in issuePickerSearch("Project Link", "filter=12345")


Which should return all Epics whose "Project Link" is on the list of the issues returned by filter


The code itself works fine, but the problem is at the very end after getQuery method of my issuePickerSearch plugin returns the results to Jira:


public Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {

BooleanQuery.Builder boolQueryBuilder = new BooleanQuery.Builder();

String searchField = operand.getArgs().get(0);
CustomField customField = customFieldManager.getCustomFieldObjectByName(searchField);

SearchService.ParseResult searchByFilter = searchService
.parseQuery(user, operand.getArgs().get(1));

if (searchByFilter.isValid()) {
SearchResults resultIssuesInFilter;

try {
List<Issue> allIssuesWithCustomField = getAllIssuesWithCustomField(customField);
resultIssuesInFilter = searchService
.search(user, searchByFilter.getQuery(), PagerFilter.getUnlimitedFilter());

List<String> matchingParentKeys = resultIssuesInFilter.getIssues().stream()

List<Issue> foundIssues =
.filter(i -> hasParentInFilter(i, matchingParentKeys, customField))


foundIssues.forEach(issue -> boolQueryBuilder
.add(new TermQuery(new Term("issue_id", issue.getId().toString())),

} catch (SearchException | NullPointerException e) {
log.error("Major search error: {}", e);
return null;




The code above throws     

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object  with class '' to class ''


How come? BooleanQuery extends Query and according to Liskov's principle should be perfectly compatible


Jira 7.2.9

Scriptrunner  5.5.9


0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

216 views 0 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you