Skip to content

fix: replace Collections.EMPTY_* with empty*() to avoid unchecked warnings#13725

Closed
Senrian wants to merge 1 commit intoapache:masterfrom
Senrian:fix/collections-empty-usage-2
Closed

fix: replace Collections.EMPTY_* with empty*() to avoid unchecked warnings#13725
Senrian wants to merge 1 commit intoapache:masterfrom
Senrian:fix/collections-empty-usage-2

Conversation

@Senrian
Copy link
Copy Markdown
Contributor

@Senrian Senrian commented Mar 4, 2026

Description

Replace deprecated Collections.EMPTY_* static fields with their empty*() method equivalents to avoid raw type warnings.

Changes

  • Replace Collections.EMPTY_MAP with Collections.emptyMap()
  • Replace Collections.EMPTY_LIST with Collections.emptyList()
  • Replace Collections.EMPTY_SET with Collections.emptySet()

This fix improves code quality by eliminating unchecked warning messages during compilation.

…nings

Replace deprecated Collections.EMPTY_LIST and Collections.EMPTY_MAP
with Collections.emptyList() and Collections.emptyMap() to eliminate
unchecked generic type warnings in Java.

Changes:
- TopNWorker.java: Collections.EMPTY_LIST -> Collections.emptyList()
- RulesReader.java: Collections.EMPTY_MAP -> Collections.emptyMap()
@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Mar 4, 2026

Could you share which warning?

@Senrian
Copy link
Copy Markdown
Contributor Author

Senrian commented Mar 4, 2026

The warning was about Collections.EMPTY_MAP being a raw type. Using Collections.emptyMap() provides proper generics and avoids the unchecked warning.

@Senrian
Copy link
Copy Markdown
Contributor Author

Senrian commented Mar 4, 2026

The warning was about Collections.EMPTY_MAP being a raw type. Using Collections.emptyMap() provides proper generics and avoids the unchecked warning. This is a Java best practice for type safety.

@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Mar 6, 2026

Duplicate with #13724, right?

@wu-sheng wu-sheng closed this Mar 6, 2026
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