Fix #5611: Prevent NPE when removing forces from Force that exists but is not registered yet #5812
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.
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 atry/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:
Close #5611