Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5611: Prevent NPE when removing forces from Force that exists but is not registered yet #5812

Merged

Conversation

Sleet01
Copy link
Collaborator

@Sleet01 Sleet01 commented Jul 28, 2024

Should fix the specific NPE from the issue, although other, similar ones may appear.

I believe the root cause is shutting down the MM host thread while it is still in the process of populating the lobby.
In the linked issue (q.v. #5611 ) the code got an NPE because it was able to get confirm that a Force existed via its ID, but was not then able to retrieve it because it had not been added to the List of Forces. Essentially, the Lobby setup and the Exit tear-down interleaved and set up a race condition leading to the Null Pointer Exception.

I don't want to just wrap the entire MM thread .start() call in a try/catch block, because it would likely swallow a number of other, more important errors. But this PR will fix the specific failure a reported.

Testing:

  • Ran with OP's campaign saves and custom files.
  • Verified no NPEs displayed after numerous attempts.
  • Ran all 3 projects' unit tests.

Close #5611

Copy link

codecov bot commented Jul 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.06%. Comparing base (8b06aec) to head (36da675).
Report is 16 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5812      +/-   ##
============================================
- Coverage     29.06%   29.06%   -0.01%     
+ Complexity    13913    13911       -2     
============================================
  Files          2507     2507              
  Lines        266339   266343       +4     
  Branches      47611    47612       +1     
============================================
- Hits          77403    77400       -3     
- Misses       185012   185021       +9     
+ Partials       3924     3922       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SJuliez SJuliez merged commit 17dde4f into MegaMek:master Jul 28, 2024
5 checks passed
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.

49.20 Nightly - NPE when closing MM after launching game from MHQ
2 participants