Skip to content

Conversation

@xiangfu0
Copy link
Contributor

Cleanup: Replace ImmutableMap.of() with Map.of()

@xiangfu0 xiangfu0 force-pushed the cleanup/replace-immutable-map-with-java-standard branch 7 times, most recently from 46e83f4 to 5f73ed1 Compare October 28, 2025 01:51
Copy link
Contributor

Copilot AI left a 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() and ImmutableMap.builder() patterns with Map.of() or Map.ofEntries()
  • Updates Map.copyOf() calls to use java.util.Map instead of Guava's ImmutableMap.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

@xiangfu0 xiangfu0 force-pushed the cleanup/replace-immutable-map-with-java-standard branch 2 times, most recently from 02aef8e to 43d321a Compare October 28, 2025 05:21
…d ImmutableMap.of; refactor imports and builders to Java Map APIs; remove unused ImmutableMap imports
@xiangfu0 xiangfu0 force-pushed the cleanup/replace-immutable-map-with-java-standard branch from 43d321a to aebfe93 Compare October 28, 2025 05:46
Copy link
Contributor

@yashmayya yashmayya left a 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?

Comment on lines +177 to +180
<!-- 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>
Copy link
Contributor

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?

Copy link
Contributor Author

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

@xiangfu0
Copy link
Contributor Author

Looks like a bunch of tests are failing due to this change?

seems to be flaky

Copy link
Contributor

@yashmayya yashmayya left a 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!

@xiangfu0 xiangfu0 merged commit bffd1e9 into apache:master Oct 28, 2025
66 of 72 checks passed
@xiangfu0 xiangfu0 deleted the cleanup/replace-immutable-map-with-java-standard branch October 28, 2025 21:13
@xiangfu0 xiangfu0 restored the cleanup/replace-immutable-map-with-java-standard branch October 29, 2025 01:34
@xiangfu0 xiangfu0 deleted the cleanup/replace-immutable-map-with-java-standard branch December 23, 2025 14:22
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.

2 participants