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

Linus Lindroth August 11, 2015

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

0 votes
Mark McCormack _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 5, 2015

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


 

0 votes
Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2015

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

0 votes
Linus Lindroth August 13, 2015

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

0 votes
Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2015

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

0 votes
Linus Lindroth August 11, 2015

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

0 votes
Linus Lindroth August 11, 2015

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?

0 votes
Linus Lindroth August 11, 2015

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.

0 votes
Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 11, 2015

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

Suggest an answer

Log in or Sign up to answer