Skip to content

Make JdkMapDiff return immutable map#88250

Merged
grcevski merged 2 commits intoelastic:masterfrom
grcevski:immutable_diff_map
Jul 6, 2022
Merged

Make JdkMapDiff return immutable map#88250
grcevski merged 2 commits intoelastic:masterfrom
grcevski:immutable_diff_map

Conversation

@grcevski
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@grcevski
Copy link
Copy Markdown
Contributor Author

grcevski commented Jul 4, 2022

@elasticmachine run elasticsearch-ci/part-1

Copy link
Copy Markdown
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
Copy Markdown
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