Hi there,
I have a custom-field in which I try to find some linked issues’ count of the issue and display it as a numeric value.
To achieve this, I’m getting the linked issues as below
IssueLinkType linkType = issueLinkTypeManager.getIssueLinkType(issueLinkTypeId);
LinkCollection issueLinks = issueLinkManager.getLinkCollection(issue, user);
List<Issue> linkedIssues = issueLinks.getOutwardIssues(linkType.getName());
return linkedIssues.size();
This custom-field also has a searcher and an indexer which gets custom-field value and indexes as below.
Object value = customField.getValue(issue);
Double indexValue = // some casting here
Field field = new Field(getDocumentFieldId(), indexValue, fieldType);
doc.add(field);
All seems fine and working so far.
Let’s say I have the ABC-123 issue which has 1 linked issue and this custom-field displays 1 as expected.
Then, I want to add another linked issue so that it would display 2.
After adding a linked issue, custom-field code is triggered by indexer and returns 1 rather than 2. As the linking operation has not been persisted yet, it returns only the old linked issue and it is being indexed as 1.
But in issue main view or in column view it is seen as 2 as expected. For sure, this causes searching and sorting problems.
Any solution for this race condition?
Thanks in advance
Tuncay