Searching for Jira issue by custom field value results in NullPointerException
症状
When performing a search including a custom field with null value or if there are invalid entries in the customfieldoption
table, JIRA will throw out the following error:
java.lang.NullPointerException
at com.atlassian.jira.issue.customfields.manager.DefaultOptionsManager.findByOptionValue(DefaultOptionsManager.java:164)
at com.atlassian.jira.issue.customfields.manager.CachedOptionsManager.findByOptionValue(CachedOptionsManager.java:95)
at com.atlassian.jira.jql.util.JqlSelectOptionsUtil.getOptionFromString(JqlSelectOptionsUtil.java:208)
at com.atlassian.jira.jql.util.JqlSelectOptionsUtil.getOptions(JqlSelectOptionsUtil.java:135)
原因
シナリオ 1
There is a null value in the customfieldoption
table. When a search is performed, it will search for all the custom field value options, so, if any of the values is null it will throw out an error.
シナリオ 2
There are entries in the customfieldoption
table that do not correspond to any custom field.
根本原因
It is yet unclear how custom field options may become unassociated from their fields, or end up with null values.
It is speculated that instability on the database connection or a Jira ungraceful termination while an operation on them was taking place could eventually lead to these residues on the database.
Alternatively, they could also be a result of direct database manipulation or database type conversion errors.
However, it was not possible to audit their origin any further.
ソリューション
After performing the steps below, if the issue persists after the reboot, ensure to run a Full re-index of the instance and verify.
Scenario 1 - UI
Perform the following query in JIRA's database, then take note of the custom fields returned;
SELECT c.cfname AS "Custom Field", o.customvalue AS "Value" FROM customfield c JOIN customfieldoption o ON c.id = o.customfield WHERE customvalue IS NULL;
- Go to Administration > Issues > Custom Field;
- Click Configure on the right of each custom field returned by the query above;
Delete any null option;
Scenario 1 - Database
データベースの変更を行う場合は 必ず事前にバックアップを取得してください。可能な場合はテスト サーバーで変更を試すことをおすすめします。
If the above fails to resolve the issue, proceed with the deletion of the null value directly on the database. For that, use the following query:
DELETE FROM customfieldoption WHERE customvalue is null;
- Restart JIRA for changes to take effect.
シナリオ 2
Perform the following query on JIRA's database to check if there are invalid entries on the
customfieldoption
table;SELECT customfield FROM customfieldoption WHERE customfield NOT IN ( SELECT id FROM customfield );
If the above query returns any result, run the query below;
DELETE FROM customfieldoption WHERE customfield NOT IN ( SELECT id FROM customfield );
Restart JIRA for changes to take effect.