Skip to content

Conversation

@ramkrishna-xyz
Copy link

This PR replaces mutableMapOf with ConcurrentHashMap for resumableSessions in SocketServer.kt. This prevents ConcurrentModificationException during session resumption and cleanup. It also adds @Suppress("DEPRECATION") to PlayerRestHandler to reduce build noise.

Replaced mutableMapOf with ConcurrentHashMap for resumableSessions in SocketServer.kt to prevent concurrent modification exceptions during session resumption and cleanup. Also suppressed deprecation warnings in PlayerRestHandler.kt to clean up the build output while maintaining backward compatibility.
@southctrl

This comment was marked as spam.

@pryzmian
Copy link

I feel like this was made with AI

@ramkrishna-xyz
Copy link
Author

@pryzmian what made you think so

@topi314
Copy link
Member

topi314 commented Dec 29, 2025

do you have an actual instance of a ConcurrentModificationException happening?

@southctrl

This comment was marked as spam.

@EvilG-MC

This comment was marked as spam.

@ramkrishna-xyz
Copy link
Author

ramkrishna-xyz commented Dec 30, 2025

While we haven't seen an actual ConcurrentModificationException crash in the logs yet, I went ahead and fixed the resumableSessions map anyway.
The original code was using a standard mutableMapOf, which isn't thread-safe. Since both the WebSocket thread (handling connections) and the background executor (handling session timeouts) touch that same map, it was a guaranteed race condition waiting to happen. I've swapped it to a ConcurrentHashMap to make it thread-safe and prevent those random crashes before they actually hit us in production.

@southctrl

This comment was marked as spam.

@ToddyTheNoobDud

This comment has been minimized.

@ramkrishna-xyz
Copy link
Author

@ToddyTheNoobDud the message was indeed ai generated because my english is like very bad so we will be in a serious type discussion here so I used ai to enhance my pull request message

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.

6 participants