fix(draft): prevent NPE when draft ends during pack-passing transition#10290
Open
billyhewlett wants to merge 1 commit intoCard-Forge:masterfrom
Open
fix(draft): prevent NPE when draft ends during pack-passing transition#10290billyhewlett wants to merge 1 commit intoCard-Forge:masterfrom
billyhewlett wants to merge 1 commit intoCard-Forge:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the final round of a draft ends while packs are still being routed
between players,
BoosterDraft.nextChoice()can returnnull. This isexpected and documented by a comment in
DraftPackPage.refresh(). However,the null-check block was missing a
returnstatement, causing execution tofall through to
cardManager.setPool(null), throwing a NullPointerException.The result: a crash/error screen appears at the end of the draft. The deck
save dialog still works, but the experience is alarming to users.
Root Cause
hasNextChoice()returnstruewhen packs are still in transit betweenplayers (round not yet over).
nextChoice()processes those pass stepsinternally via a recursive
passPacks()call, which can drain all remainingpacks and return
nullif no new round can be started. The gap between thetwo checks is where the null slips through.
Fix
Add
return;afterparentScreen.completeDraft()in the null-pool branchof
DraftPackPage.refresh().Testing
Reproduce by completing any cube or custom draft to the final pick. The
crash screen no longer appears.