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

Issue #2597: Add thread safety to duplicate name hash #2632

Conversation

sixlettervariables
Copy link
Contributor

The duplicate name protection code used a Hashtable which is thread safe, however, performing multiple operations is not atomic. This switches to use a lock to synchronize access to duplicate name generation. This also adds a lock to synchronize setting the short and display names. This makes both operations atomic and idempotent.

I don't think this is necessary for 0.48.

@sixlettervariables
Copy link
Contributor Author

I should add I was unable to replicate the original issue.

Copy link
Contributor

@Windchild292 Windchild292 left a comment

Choose a reason for hiding this comment

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

Just two comments on variable name oddities

megamek/src/megamek/common/Entity.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/Entity.java Outdated Show resolved Hide resolved
@Windchild292
Copy link
Contributor

Your discretion on 0.48, especially given MegaMek/mekhq#2412

@sixlettervariables
Copy link
Contributor Author

I have never been able to reproduce this, so it may be worth seeing if one of the bug reporters can test a snapshot of this.

@sixlettervariables sixlettervariables merged commit 7c57ed4 into MegaMek:master Mar 17, 2021
@sixlettervariables sixlettervariables deleted the issue-2597-protect-duplicate-name-hash branch March 17, 2021 16:26
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.

None yet

3 participants