Fix #7338: SEVERE log on shutdown when skill table re-sorts after close#7589
Open
Vest wants to merge 1 commit into
Open
Fix #7338: SEVERE log on shutdown when skill table re-sorts after close#7589Vest wants to merge 1 commit into
Vest wants to merge 1 commit into
Conversation
…seCharacter (PCGen#7338) CharacterFacadeImpl.closeCharacter notes that "a dummy rather than null is necessary because the UI does model swaps and such that do not pause events" and assigns DUMMY_PC. CharacterLevelsFacadeImpl.closeCharacter ignored the same constraint and assigned theCharacter = null. The mismatch surfaces during macOS Cmd-Q shutdown: CharacterFacadeImpl.closeCharacter 1. charLevelsFacade.closeCharacter() -> theCharacter = null 2. dataSet.detachDelegates() -> fires list-change events -> FilteredTreeViewModel.refilter -> TreeViewTableModel resort -> RowComparator.compare -> SkillTreeViewModel.getData -> CharacterLevelsFacadeImpl.getSkillBreakdown(level, skill) -> SkillRankControl.getTotalRank(null, skill) getTotalRank null-guards and returns 0, but logs SEVERE with a stack trace, producing the noise reported in the ticket. Mirror the parent facade's pattern: assign a static placeholder PlayerCharacter (CLOSED_PC) instead of null. Empty-but-valid state lets mid-teardown UI events read sane values without triggering downstream null-guard logging. Local change; doesn't touch the parent facade. Adds CharacterLevelsFacadeImplTest#testGetSkillBreakdownAfterCloseCharacterDoesNotLogError which captures SEVERE log records via a JUL handler around closeCharacter + getSkillBreakdown. Fails on master with the exact ticket stack trace; passes after the fix.
Contributor
Author
|
Manually verified on macOS: loaded a character, hit ⌘Q. The shutdown log no longer contains the |
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 #7338 — on macOS Cmd-Q shutdown (and any path that calls
closeAllCharacterswhile the Skill tab is mounted),SkillRankControl.getTotalRankis invoked with a nullPlayerCharacter, producing a noisy SEVERE log with stack trace. The shutdown completes correctly; the user just sees a scary trace in the log.Root cause
CharacterFacadeImpl.closeCharacteralready documents the relevant invariant explicitly:CharacterLevelsFacadeImpl.closeCharacterdid not follow the same pattern — it assignedtheCharacter = null. During teardown,dataSet.detachDelegates()fires list-change events that propagate up to the skill tree's row comparator (RowComparator.compare→SkillTreeViewModel.getData→CharacterLevelsFacadeImpl.getSkillBreakdown→SkillRankControl.getTotalRank(null, skill)). The null guard atSkillRankControl.java:64-67swallows the NPE but emits a SEVERE record with anew Throwable()for diagnostics — that's the ticket symptom.Fix
Mirror the parent facade's pattern: introduce a static placeholder
CLOSED_PCand assign it instead of null. Empty-but-valid PC state lets mid-teardown UI events read sane defaults without triggering downstream null-guard logging.Two-line behavioral change, scoped to
CharacterLevelsFacadeImpl. Does not modifyCharacterFacadeImplor any other facade.Test plan
CharacterLevelsFacadeImplTest#testGetSkillBreakdownAfterCloseCharacterDoesNotLogError— installs a JULHandlercapturing SEVERE records, callscloseCharacter(), thengetSkillBreakdown(level, skill)(the exact path on the bug's stack trace), and asserts no SEVERE record was emitted.Asked to get total rank for null character ... at SkillRankControl.getTotalRank(SkillRankControl.java:66) at CharacterLevelsFacadeImpl.getSkillBreakdown(CharacterLevelsFacadeImpl.java:394))../gradlew :slowtest --tests 'pcgen.gui2.facade.CharacterLevelsFacadeImplTest').cc @Azhrei — would you mind retrying the macOS Cmd-Q repro on this branch when you get a chance? The unit test reproduces the same
getTotalRankSEVERE log via the same call chain you reported, and stops emitting it after this change.