Reindex listener doesn't update parent issue when sub-task is created

Hi

I'm using the solution from Riada https://riada.se/blog/sana/estimate-your-sub-tasks-in-jira-agile/ to be able to use the summed up Estimate from the sub-tasks instead of the Estimate only from the Story in a Scrum board. So I want the sub-tasks to roll up to the Estimate value which it does, but not immediately. 

I also have a listener that does reindex/update both the issue itself and its parent (if it has one). But when I create a sub-task and set an Original Estimate, the parent Issues Estimate field (and the scripted field that contain the sum) doesn't change until I do some update like edit, change the ranking or such on the parent issue. The idea with the listener is of course that the changes should be instant. But if I for example remove a sub-task the value updates instantly so it seems to be that the reindex listener misses out that I have created a sub-task?? The sub task fires an Issue Created event and I also added the reindex post function but it doesn't help.

Does anyone have any idea why the listener doesn't run when creating the sub-task?

This is basically the interesting part of the reindex listener:

@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
	Long eventTypeId = issueEvent.getEventTypeId();
	Issue issue = issueEvent.getIssue();
	Issue parent = issue.getParentObject();
	// if an event is triggered, re-index
	if (!eventTypeId.equals(EventType.ISSUE_DELETED_ID)){
		reIndexIssue(issue);
		if (parent != null) {
			reIndexIssue(parent);
		}
	}
}

8 answers

This widget could not be displayed.

Hi Linus, Did you try adding some log messages inside the onIssueEvent method to verify that the listener is not called?

This widget could not be displayed.

No I didn't unfortunately because I couldn't really figure out how to introduce log messages to any log I can read. But basically if it would run it would fix the calculation I guess. To me it seems like it is invoked before the value of the sub-tasks original estimate is updated or something...could that be the case? Next time the parent issue is updated it gets fixed.

This widget could not be displayed.

Perhaps I should add that the scripted field goes through all sub-tasks of an issue and sum up their original estimate values, this value is then being written to another numeric field that is used as Estimate. My feeling is that there is some sort of lag when creating a new sub-task so even if the listener is called it doesn't get the new value in time. Do you know how to enable logging in the listener?

This widget could not be displayed.

This is part of the listener but where does System.out.println("Reindex error!!") end up? In what file? public void reIndexIssue(Issue issue){ boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); try { ComponentAccessor.getIssueIndexManager().reIndex(issue); } catch (IndexException e) { System.out.println("Reindex error!!"); }finally{ ImportUtils.setIndexIssues(wasIndexing); } }

This widget could not be displayed.

It could be that the timings are not the right ones, but I guess you can find out more information adding some logging. Below is an example of a listener with logging: class ExampleListener extends AbstractIssueEventListener { Category log = Category.getInstance(ExampleListener.class) @Override void workflowEvent(IssueEvent event) { log.debug "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by ExampleListener" } }

This widget could not be displayed.

Ok I will see if I can remember how to recompile the listener. Thank you.

This widget could not be displayed.

If you just update the groovy class it will be reloaded automatically. So there is no need to recompile it.

This widget could not be displayed.

Changing Alejo's comment to an answer so that this shows up as answered:

Below is an example of a listener with logging:

class ExampleListener extends AbstractIssueEventListener { 
	Category log = Category.getInstance(ExampleListener.class) 
 
	@Override 
	void workflowEvent(IssueEvent event) { 
		log.debug "Event: ${event.getEventTypeId()} 
			fired for ${event.issue} and caught by ExampleListener" 
	} 
}


 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

216 views 3 0
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