Skip to content

Fix two error-prone warnings in tests#51

Merged
nlativy merged 1 commit into
masterfrom
fix-errorprone-warnings
Apr 26, 2026
Merged

Fix two error-prone warnings in tests#51
nlativy merged 1 commit into
masterfrom
fix-errorprone-warnings

Conversation

@nlativy
Copy link
Copy Markdown
Collaborator

@nlativy nlativy commented Apr 26, 2026

Summary

  • GuiceberryCompatibilityModuleTest.testWrapperExceptionPropagated was using the legacy try/catch-and-swallow idiom to assert that a TestException is thrown. Error-prone's EmptyCatch flagged the swallowed exception. Replaced with assertThrows, which states the intent explicitly.

  • DependenciesTest.arbitraryOrdering passed new ServiceA() twice in an ImmutableSet.of varargs call. DistinctVarargsChecker flags this as the kind of thing that is almost always a copy-paste bug. The test only asserts that Dependencies.inOrder returns every input service for a set with no @DependsOn relationships — two distinct services express that equally well.

Test plan

  • mvn -B clean test — 43/43 pass
  • No more EmptyCatch or DistinctVarargsChecker warnings in the build output

GuiceberryCompatibilityModuleTest.testWrapperExceptionPropagated
swallowed the expected exception in an empty catch block. Replace
the try/catch idiom with assertThrows, which both states the intent
explicitly and silences the EmptyCatch warning.

DependenciesTest.arbitraryOrdering passed `new ServiceA()` twice in
an ImmutableSet.of varargs, which DistinctVarargsChecker flags as
the kind of thing that's almost always a copy-paste bug. The test
just asserts that inOrder() returns every input service for an
unrelated set, which two distinct services express equally well.
@nlativy nlativy merged commit c315e15 into master Apr 26, 2026
3 checks passed
@nlativy nlativy deleted the fix-errorprone-warnings branch April 26, 2026 22:07
@nlativy nlativy mentioned this pull request Apr 26, 2026
1 task
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.

1 participant