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

ConcurrentModificationException when using broadcast #902

Merged
merged 3 commits into from
Jul 10, 2019

Conversation

marci4
Copy link
Collaborator

@marci4 marci4 commented Jun 11, 2019

Description

It is possible to have get a ConcurrentModificationException when using broadcast and a new client connects/drops

Related Issue

Found with #879

Motivation and Context

Bugfix

How Has This Been Tested?

Developed test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Fix ConcurrentModificationException found during the investigation of TooTallNate#879
Reduce the number of tests
@maiph
Copy link
Contributor

maiph commented Jun 12, 2019

Wouldn't it be better to make a copy of the list of clients inside a synchronization block and then loop over it?
Also, having it this way wouldn't it block the server thread while all the frames are being created ? And therefore block any operations on the clients list.

@marci4
Copy link
Collaborator Author

marci4 commented Jun 12, 2019

@maiph yeah good point. Will change it later!

Copy the clients into a local list
@marci4
Copy link
Collaborator Author

marci4 commented Jun 14, 2019

@maiph could you maybe give me feedback to my second changes? Thank you :)

@marci4 marci4 removed the Client label Jun 14, 2019
@marci4 marci4 merged commit dc080e0 into TooTallNate:master Jul 10, 2019
@marci4 marci4 deleted the 879Concurrent branch July 10, 2019 20:50
@hovis
Copy link
Contributor

hovis commented Jul 29, 2019

The implementation of getConnections() should also be synchronized on the connections variable whilst it does a new ArrayList()

@marci4
Copy link
Collaborator Author

marci4 commented Jul 30, 2019

@hovis please open an fresh issue and a new PR. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants