Skip to content

Fix: add null guard after ReadAll() in GetRaceDataOfDay#20

Open
HashidaTKS wants to merge 1 commit into
masterfrom
fix/readall-null-check
Open

Fix: add null guard after ReadAll() in GetRaceDataOfDay#20
HashidaTKS wants to merge 1 commit into
masterfrom
fix/readall-null-check

Conversation

@HashidaTKS
Copy link
Copy Markdown
Owner

問題点

RaceDataManager.GetRaceDataOfDay()holdingInformationRepository.ReadAll() の戻り値を null チェックせずに currentHoldingInformation.HoldingData.Where(...) を呼び出していた。

ReadAll() は XMLファイルが存在しない場合(初回起動時やキャッシュリセット後など)に null を返すため、NullReferenceException が発生する可能性があった。

改善内容

  • ReadAll() の結果が null の場合は yield break で早期リターンするガード節を追加
  • GetAndStoreRaceDataOfDay() は既に ?? new HoldingInformation(...) で対処済みのため変更不要

Test plan

  • holding_info.xml が存在しない状態で GetRaceDataOfDay を呼び出しても例外が発生しないことを確認
  • 通常状態(ファイルあり)での動作が変わらないことを確認

🤖 Generated with Claude Code

…llReferenceException

ReadAll() returns null when the XML file does not exist. GetRaceDataOfDay
was accessing currentHoldingInformation.HoldingData without a null check,
which would throw NullReferenceException on first run or after cache reset.
Add an explicit null check and yield break to handle the no-data case safely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant