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

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

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.

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 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); } }

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" } }

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

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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

215 views 4 9
Read article

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