Skip to content

Make JdkMapDiff return immutable map #88250

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

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

grcevski
Copy link
Contributor

@grcevski grcevski commented Jul 4, 2022

When using the DiffableUtils.diff with a vanilla OpenJDK Map, instead of the legacy ImmutableOpenMap interface, we return a mutable map (generic HashMap), which isn't the expected behaviour of the API:

elasticsearch/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java
Line 85 in 45c56b2
public static <K, T extends Diffable> MapDiff<K, T, Map<K, T>> diff(

This PR wraps the Map returned from the diff.apply() method to return an immutable map collection.

Closes #88019

@grcevski grcevski added >non-issue :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team v8.4.0 labels Jul 4, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@grcevski
Copy link
Contributor Author

grcevski commented Jul 4, 2022

@elasticmachine run elasticsearch-ci/part-1

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

LGTM.

@grcevski grcevski merged commit 55fd4c6 into elastic:master Jul 6, 2022
@grcevski grcevski deleted the immutable_diff_map branch July 6, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DiffableUtils.diff should return an Immutable Map when used with a JDK Map
4 participants