Skip to content

[improve][test] Fix unchecked compile warnings in test code#25431

Merged
merlimat merged 5 commits intoapache:masterfrom
merlimat:fix-test-warnings-4
Mar 31, 2026
Merged

[improve][test] Fix unchecked compile warnings in test code#25431
merlimat merged 5 commits intoapache:masterfrom
merlimat:fix-test-warnings-4

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Motivation

Fix unchecked compiler warnings in test code — unchecked casts and generic array creation due to type erasure.

This is part of a series to clean up test compile warnings (following production code cleanup in #25414-#25422).

Changes

  • Add @SuppressWarnings("unchecked") at method or variable level for unavoidable Mockito mock casts (type erasure prevents parameterized mock casts at runtime)
  • Use doReturn().when() instead of when().thenReturn() where wildcard capture causes unchecked warnings
  • Add @SafeVarargs for varargs utility methods that only read from the array
  • Fix generic array creation warnings in test utility methods

Affects ~213 files across all modules.

Verifying this change

  • ./gradlew compileTestJava passes cleanly
  • unchecked warning count drops to zero

Does this pull request potentially affect one of the following areas?

  • Test code only

Documentation

  • doc-not-needed — test-only changes

Fix unchecked warnings across test code:
- Add @SuppressWarnings("unchecked") for Mockito mock casts and
  generic array creation (unavoidable in Java)
- Convert when().thenReturn() to doReturn().when() for wildcard
  capture issues
- Add type parameters to raw constructors and declarations
- Add @SafeVarargs for varargs utility methods
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 29, 2026
@merlimat merlimat merged commit f048a84 into apache:master Mar 31, 2026
79 of 81 checks passed
@merlimat merlimat deleted the fix-test-warnings-4 branch March 31, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants