Conversation
The !! on newStack[BountifulContent.DECREE_DATA] caused a server freeze (ServerHangWatchdog) when the data component was absent on a decree stack — for example when a stack was duplicated out-of-band (creative pick-block on a board slot, modded item manipulation, or NBT-cleared stack from another mod). Replace the unsafe non-null assertion with an early return, matching the null-safe patterns already used elsewhere in the file (e.g. line 140 / BOUNTY_INFO usage at line 295). Fixes ejektaflex#336
Owner
|
I'm a bit hesitant to merge this because the fix hasn't been tested, and it pulls in AI comments. I'll make the change locally and validate before releasing a new version. |
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.
Summary
Fixes the server-freeze crash described in #336.
BoardBlockEntity.checkUserPlacedAllDecreesused a non-null assertion (!!) on theDECREE_DATAdata component. When the component was absent — for example on a decree stack duplicated out-of-band (creative pick-block on a board slot, modded item manipulation, or an NBT-cleared stack from another mod) — the!!threw an NPE on the server thread, which the ServerHangWatchdog then escalated into a full server freeze several minutes later.Fix
Replace the
!!with an early return, matching the null-safe patterns already used elsewhere in this file:it[BountifulContent.DECREE_DATA]?.ids ?: emptySet()val info = stack[BountifulContent.BOUNTY_INFO] ?: continueThe
count == 0early return above already covers the consumed-stack case, so the new?: returnonly triggers on the truly null-component case the!!was crashing on.Reproduction
Per the issue:
The crash report points to line 271, which was the
!!expression in the original source (and is thedecreeData = …line in this PR's diff). Lines and surrounding context match the reported stack trace.Risk
Trivial. One-line behavioural change (skip the function instead of crashing) on a code path that previously took the server down. No public API changes, no new imports.