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

[MNG-8014] Fix multithreaded builder #1386

Merged
merged 5 commits into from
Jan 22, 2024

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Jan 19, 2024

No description provided.

@gnodet gnodet requested a review from cstamas January 19, 2024 10:33
import java.util.function.Predicate;
import java.util.function.UnaryOperator;

class ImmutableCollections {
Copy link
Member

Choose a reason for hiding this comment

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

why? Why over Collections?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same classes are used in the immutable classes generated from the modello schemas.
Those are similar to the new Map.of() and List.of() in recent JDKs.
The main benefit is that there's no copy if you ask for an immutable collection if you pass an already immutable collection (this list is always wrapped in JDK 8) and there's no safe copy, i.e. the unmodifiable collection is just a wrapper on top of the collection, so it's still can be modified, so one needs to do a copy first.
Bottom line, the current code is actually using Collections.unmodifiableMap(new HashMap<>(attributes)) which is quite expensive.

If we were to raise the runtime requirement to JDK 9, I'd happily get rid of those.

Copy link
Member

@cstamas cstamas left a comment

Choose a reason for hiding this comment

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

LGTM

@gnodet gnodet added this to the 4.0.0-alpha-13 milestone Jan 19, 2024
@gnodet gnodet merged commit b6a84fc into apache:master Jan 22, 2024
18 checks passed
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.

2 participants