NullPointerException in getFieldConfig

XMLWordPrintable

    • 6.04
    • 5
    • Severity 2 - Major
    • 2

      Summary

      In some rare cases, JIRA has consistency problems with CustomFields, this will lead to NullPointerException in getFieldConfig method.
      And that could lead to other problems related to ProjectSidebarRenderer not able to load the data.

      Steps to Reproduce

      1. Create CF data inconsistency
      2. Create Filter containing CF using values from inconsistent data
      3. Load any issue

      Expected Results

      JIRA works fine.

      Actual Results

      JIRA can't render sidebar: Unable to render element due to an error

      The below exception is thrown in the jira logs:

      Caused by: java.lang.NullPointerException
      	at com.atlassian.jira.issue.fields.config.persistence.FieldConfigPersisterImpl.getFieldConfig(FieldConfigPersisterImpl.java:170)
      	at com.atlassian.jira.issue.fields.config.manager.FieldConfigManagerImpl.getFieldConfig(FieldConfigManagerImpl.java:30)
      	at com.atlassian.jira.issue.customfields.option.LazyLoadedOption$1.create(LazyLoadedOption.java:31)
      	at com.atlassian.jira.issue.customfields.option.LazyLoadedOption$1.create(LazyLoadedOption.java:28)
      	at com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:325)
      	at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)
      	at com.atlassian.jira.issue.customfields.option.LazyLoadedOption.getRelatedCustomField(LazyLoadedOption.java:42)
      	at com.atlassian.jira.plugins.issue.create.context.fields.helpers.SelectableCustomCFTypeJQLMapper$$anonfun$filterOnlyRelevantOptions$1$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(SelectableCustomCFTypeJQLMapper.scala:19)
      	at com.atlassian.jira.plugins.issue.create.context.fields.helpers.SelectableCustomCFTypeJQLMapper$$anonfun$filterOnlyRelevantOptions$1$$anon
      ...
      	at com.atlassian.jira.plugins.issue.create.context.fields.helpers.GenericClauseInputMapper$class.apply(GenericClauseInputMapper.scala:15)
      	at com.atlassian.jira.plugins.issue.create.context.fields.custom.SelectCFTypeJQLMapper.apply(SelectCFTypeJQLMapper.scala:13)
      ...
      	at com.atlassian.jira.plugins.issue.create.context.InputParamsBuilder.contextForPossibleValues(InputParamsBuilder.scala:99)
      	at com.atlassian.jira.plugins.issue.create.rest.ContextResolutionHelper.possibleValuesForClause(ContextResolutionHelper.scala:48)
      	at com.atlassian.jira.plugins.issue.create.rest.ContextResolutionHelper.possibleValuesForIssueInput(ContextResolutionHelper.scala:55)
      	at com.atlassian.greenhopper.service.query.FieldPossibleValuesAdapterImpl.possibleValuesForIssueInput(FieldPossibleValuesAdapterImpl.java:21)
      	at com.atlassian.greenhopper.service.query.FieldPossibleValues.getProjectIdsForQuery(FieldPossibleValues.java:38)
      ...
      	at com.atlassian.greenhopper.service.query.QueryToProjectMapper.getProjectContextIdsForQuery(QueryToProjectMapper.java:78)
      	at com.atlassian.greenhopper.service.query.QueryServiceImpl.getProjectsForRapidView(QueryServiceImpl.java:123)
      	at com.atlassian.greenhopper.service.query.QueryServiceImpl.getExplicitProjectsForRapidViewFilterQuery(QueryServiceImpl.java:110)
      	at com.atlassian.greenhopper.service.rapid.ProjectRapidViewServiceImpl.findProjectsByRapidView(ProjectRapidViewServiceImpl.java:69)
      	at com.atlassian.greenhopper.service.rapid.ProjectRapidViewServiceImpl.findRapidViewsByProject(ProjectRapidViewServiceImpl.java:51)
      	at com.atlassian.greenhopper.web.sidebar.ProjectBoardsHelper.getProjectBoards(ProjectBoardsHelper.java:53)
      	at com.atlassian.greenhopper.web.sidebar.BoardScopeFilterContextProviderImpl.getContext(BoardScopeFilterContextProviderImpl.java:47)
      	at com.atlassian.jira.projects.context.ProjectContextPopulatorImpl.populateWithProject(ProjectContextPopulatorImpl.java:82)
      	at com.atlassian.jira.projects.sidebar.footer.ProjectAdminLinkService.getProjectConfigUrlOverride(ProjectAdminLinkService.java:90)
      	at com.atlassian.jira.projects.sidebar.footer.ProjectAdminLinkService.getAdminUrl(ProjectAdminLinkService.java:75)
      	at com.atlassian.jira.projects.sidebar.footer.ProjectAdminLinkService.getLinkForProject(ProjectAdminLinkService.java:57)
      	at com.atlassian.jira.projects.sidebar.ProjectSidebarRendererImpl.render(ProjectSidebarRendererImpl.java:102)
      ...
      

      Notes

      Possibly caused by JRA-19422, which was fixed in JIRA 4.0.1.
      Problem: When deleting a custom field context for a select custom field, the options created are not deleted. They remain in the customfieldoption table, with references to a fieldconfiguration (custom field context) that no longer exists (because it was deleted).

      The table structure for involved tables: fieldconfigschemeissuetype, fieldconfiguration, fieldconfigscheme, customfieldoption

      • fieldconfigschemeissuetype.fieldconfiguration maps to fieldconfiguration.id
      • fieldconfigschemeissuetype.fieldconfigscheme maps to fieldconfigscheme.id
      • customfieldoption.customfieldconfig maps to fieldconfiguration.id

      You can check data consistency by running followings SQLs

      // Check orphaned records in fieldconfiguration vs fieldconfigschemeissuetype 
      select fc.id from fieldconfiguration fc left join fieldconfigschemeissuetype fcsit on (fc.id = fcsit.fieldconfiguration) where fcsit.id is null order by fc.id;
      
      // Check orphaned records in fieldconfigschemeissuetype vs  fieldconfiguration 
      select fcsit.id,fcsit.fieldconfiguration from fieldconfigschemeissuetype fcsit left join fieldconfiguration fc on (fc.id = fcsit.fieldconfiguration) where fc.id is NULL;
      
      // Check orphaned records in customfieldoption vs fieldconfiguration 
      select distinct(customfieldconfig) from customfieldoption where customfieldconfig not in (select id from fieldconfiguration );
      

      They should return 0 records in normal condition.

      Workaround

      See KBs:

            Assignee:
            Przemyslaw Czuj (Inactive)
            Reporter:
            Andriy Yakovlev [Atlassian]
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: