Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-12974

Sorting by work-ratio breaks if no issues have an original estimate

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Medium
    • 3.10.2
    • 3.9.1, 3.9.2, 3.10
    • Indexing

    Description

      Sorting by work-ratio doesn't work, if no issues have an original estimate set. The outcome for a user is that if you try to sort, you'll get a RuntimeException in your browser:

      java.lang.RuntimeException: no terms in field workratio
      at com.atlassian.jira.issue.search.parameters.lucene.sort.JiraLuceneFieldCache.getCustom(JiraLuceneFieldCache.java:36)
      at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator.getComparatorUsingTerms(MappedSortComparator.java:40)
      at com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator.newComparator(MappedSortComparator.java:34)
      at org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSortedHitQueue.java:197)
      at org.apache.lucene.search.FieldSortedHitQueue.<init>(FieldSortedHitQueue.java:58)
      at org.apache.lucene.search.TopFieldDocCollector.<init>(TopFieldDocCollector.java:44)
      at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:108)
      at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:65)
      at org.apache.lucene.search.Hits.<init>(Hits.java:52)
      at org.apache.lucene.search.Searcher.search(Searcher.java:62)
      at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.runSearch(LuceneSearchProvider.java:136)
      at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.getHits(LuceneSearchProvider.java:68)
      at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:195)
      at com.atlassian.jira.web.action.issue.IssueNavigator.getSearchResults(IssueNavigator.java:355)
      at com.atlassian.jira.web.action.issue.IssueNavigator.getBrowsableItems(IssueNavigator.java:326)
      at com.atlassian.jira.web.action.issue.IssueNavigator.doExecute(IssueNavigator.java:203)
      at webwork.action.ActionSupport.execute(ActionSupport.java:153)
      at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:54)
      at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:132)
      at com.atlassian.jira.web.dispatcher.JiraServletDispatcher.service(JiraServletDispatcher.java:209)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
      at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
      ...
      

      The reason for this is that the WorkRatioIndexer does not index anything if the original estimate is null:

              // Add actual vs estimated work ratio to index for range query - only add work ratio if a time estimate for issue exists
              if (issue.getOriginalEstimate() != null)
              {
                  doc.add(Field.Keyword(DocumentConstants.ISSUE_WORKRATIO, WorkRatio.getPaddedWorkRatio(issue.getGenericValue())));
              }
      

      Our sorting code (the JiraLuceneFieldCache) in particular can't handle the case where there's no terms for a field yet:

      if (termEnum.term() == null)
                          {
                              throw new RuntimeException("no terms in field " + field);
                          }
      

      We need to fix either the sorting, or indexing. (Sorting's probably the safer way to go about it in the long run.)

      Attachments

        Activity

          People

            Unassigned Unassigned
            andreask@atlassian.com Andreas Knecht (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified