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

Rework XStream initialization #352

Merged
merged 4 commits into from
Jan 25, 2021
Merged

Rework XStream initialization #352

merged 4 commits into from
Jan 25, 2021

Conversation

xeruf
Copy link
Member

@xeruf xeruf commented Jan 13, 2021

Due to the tests now running in parallel, we sometimes had ConcurrentModificationExceptions since the global XStream instance was initialized in parallel from different threads.

Now all initialization points are locked.

Copy link
Contributor

@anarchuser anarchuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the problem is concurrent invocation of registerXStream, wouldn't it be more sensible to make GamePlugin a singleton?

@xeruf
Copy link
Member Author

xeruf commented Jan 13, 2021

That function is already static. That doesn't solve the concurrency problem, unfortunately.

@xeruf
Copy link
Member Author

xeruf commented Jan 13, 2021

I have run all tests repeatedly locally with no failure. The one failing test has been unreliable for a while, I'll see whether I have to Disable it or find a fix.

@anarchuser
Copy link
Contributor

anarchuser commented Jan 13, 2021

As far as I can tell, that function is only called on initialisation of GamePlugin, right?

@xeruf
Copy link
Member Author

xeruf commented Jan 13, 2021

you're right, the concurrency issues occur only in the tests. Hmm...

Copy link
Contributor

@SKoschnicke SKoschnicke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are succeeding on my machine with the current state 👍

plugin/src/server/sc/plugin2021/GamePlugin.kt Outdated Show resolved Hide resolved
@anarchuser
Copy link
Contributor

I think the actual issue is still why that function is being called several types at all

@xeruf
Copy link
Member Author

xeruf commented Jan 14, 2021

As said, parallelized tests

@anarchuser
Copy link
Contributor

yes, but this should be setup stage for tests. This shouldn't be something several tests initialise for themselves anyways.

@xeruf
Copy link
Member Author

xeruf commented Jan 14, 2021

yeah, the question is whether there is a way to have global setup for independent tests.

@xeruf
Copy link
Member Author

xeruf commented Jan 18, 2021

hello it's me, giant commit 😄 yes I just changed a lot of code. I will also add some documentation for that in the GUIDELINES soon. But unlike last time, where I made the XStream instance global (brevity at the expense of creating global state, which is the opposite of clean code ^^), this really does make the code a whole lot cleaner (which we can partly see through the application of the design patterns Factory + Template Method)!

@xeruf xeruf changed the title fix: synchronize XStream initialization Rework XStream initialization Jan 18, 2021
@xeruf xeruf mentioned this pull request Jan 21, 2021
Due to the tests now running in parallel, we sometimes had
ConcurrentModificationExceptions since the global XStream instance was
initialized in parallel from different threads.

Now all initialization points are locked.
…tener

Thus we save the synchronization overhead.
@xeruf xeruf mentioned this pull request Jan 21, 2021
Copy link
Contributor

@SKoschnicke SKoschnicke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@xeruf xeruf merged commit 2828849 into master Jan 25, 2021
@xeruf xeruf deleted the xstream-synchronization branch January 25, 2021 13:33
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.

3 participants