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

Copy constructors should copy mutable MergePolicyConfig objects and not share them #17993

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

pivovarit
Copy link
Contributor

@pivovarit pivovarit commented Dec 21, 2020

Some of the existing copy-constructors are introducing shared mutability by reusing existing config objects instead of creating fresh copies which can lead, for example, to unsolicited changes in default configurations.

Config config = new Config();
ScheduledExecutorConfig newConfig = config.getScheduledExecutorConfig("nonexisting");
ScheduledExecutorConfig defaultConfig = config.getScheduledExecutorConfig("default");

newConfig.getMergePolicyConfig().setPolicy("spanish inquisition!");

defaultConfig.getMergePolicyConfig().getPolicy(); // spanish inquisition!

Related: #17874

@pivovarit pivovarit changed the title Copy constructors should copy mutable config objects and not share them Copy constructors should copy mutable MergePolicyConfig objects and not share them Dec 21, 2020
@pivovarit pivovarit marked this pull request as ready for review December 21, 2020 22:34
@hazelcast hazelcast deleted a comment Dec 21, 2020
@pivovarit pivovarit added this to the 4.2 milestone Dec 22, 2020
@pivovarit pivovarit requested review from mmedenjak and removed request for blazember December 22, 2020 09:04
@pivovarit pivovarit requested review from blazember and removed request for jerrinot December 30, 2020 09:24
@pivovarit pivovarit merged commit cee728c into hazelcast:master Jan 4, 2021
@pivovarit pivovarit deleted the fix-copy-constructor branch January 4, 2021 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants