-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Cleanup: Replace ImmutableMap.of() with Map.of() #17091
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
Cleanup: Replace ImmutableMap.of() with Map.of() #17091
Conversation
46e83f4 to
5f73ed1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces Guava's ImmutableMap.of() with Java's native Map.of() throughout the codebase. The change modernizes the code by using Java's built-in collections factory methods introduced in Java 9, reducing dependency on the Guava library. Additionally, a checkstyle rule is added to prevent future use of ImmutableMap.
Key changes:
- Replaces all instances of
ImmutableMap.of()andImmutableMap.builder()patterns withMap.of()orMap.ofEntries() - Updates
Map.copyOf()calls to usejava.util.Mapinstead of Guava'sImmutableMap.copyOf() - Adds a checkstyle rule to disallow importing
com.google.common.collect.ImmutableMap
Reviewed Changes
Copilot reviewed 82 out of 82 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| config/checkstyle.xml | Adds checkstyle rule to prevent ImmutableMap imports |
| Multiple production files | Replaces ImmutableMap.of() with Map.of() and ImmutableMap.copyOf() with Map.copyOf() |
| Multiple test files | Replaces ImmutableMap.of() with Map.of() in test code |
| pinot-common/src/main/codegen/templates/Parser.jj | Removes unused ImmutableMap import |
...gration-tests/src/test/java/org/apache/pinot/integration/tests/tpch/TblToAvroMultiValue.java
Show resolved
Hide resolved
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/tpch/TblToAvro.java
Show resolved
Hide resolved
02aef8e to
43d321a
Compare
…d ImmutableMap.of; refactor imports and builders to Java Map APIs; remove unused ImmutableMap imports
43d321a to
aebfe93
Compare
yashmayya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a bunch of tests are failing due to this change?
| <!-- Disallow importing com.google.common.collect.ImmutableMap (use java.util.Map instead) --> | ||
| <module name="IllegalImport"> | ||
| <property name="illegalClasses" value="com.google.common.collect.ImmutableMap"/> | ||
| </module> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this rule needed - did we find any issues in Guava's immutable map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just it's just for code conventions
seems to be flaky |
yashmayya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup!
Cleanup: Replace ImmutableMap.of() with Map.of()