fix: avoid re-fetching connected server in handle(ClientSettingsPacket) - #1850
Open
qventymr wants to merge 1 commit into
Open
fix: avoid re-fetching connected server in handle(ClientSettingsPacket)#1850qventymr wants to merge 1 commit into
qventymr wants to merge 1 commit into
Conversation
Member
|
I don't think this is an actual improvement outside of flow correction, this stuff, along with server transfer invocations, should occur on the event loop and so there should be no risk of something side-sweeping in here |
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.
What
ClientPlaySessionHandler#handle(ClientSettingsPacket)fetchesplayer.getConnectedServer(), null-checks it, then discards the localvariable and calls
player.getConnectedServer()a second time beforecalling
.ensureConnected()on the result.Between these two calls the player's connected server can change on
another thread (e.g. mid server-switch), so the second call can return
null(NPE on.ensureConnected()) or a connection whoseensureConnected()throwsIllegalStateException, crashing/kickingthe session — the same class of bug fixed for the chat/command packet
handlers in f6fbd25 ("Downgrade severity of handling several incoming
user input packet states"), which however did not touch this handler.
Fix
Reuse the already null-checked local
serverConnectionreferenceinstead of re-querying
player.getConnectedServer().Testing
Built locally with
./gradlew build; no behavioral change for thenon-racy path, since the second
getConnectedServer()call previouslyreturned the same object in the common case.