Searching for Jira issue by custom field value results in NullPointerException
プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。
このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
症状
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
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
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.