Skip to content

Commit a9eab60

Browse files
java-team-github-botError Prone Team
authored andcommitted
Add some suggestions for Future in UndefinedEquals.md (the actual logic was added in 1046226 but the linked documentation doesn't offer any suggestions).
PiperOrigin-RevId: 774759018
1 parent 51907a0 commit a9eab60

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

docs/bugpattern/UndefinedEquals.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ TIP: `java.util.Date` is a legacy, bug-prone API. Prefer `java.time.Instant` or
6262
Prefer subtypes such as `ImmutableSet` or `ImmutableList`, which have
6363
well-defined `equals`.
6464

65+
## For [`Future`]
66+
67+
Prefer calling `#get` and checking the result, or using
68+
`assertThat(...).isSameInstanceAs()` or `assertThat(...).isNotSameInstanceAs()`
69+
for cases where the same/different instance is expected.
70+
6571
[`Collection`]: https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html
72+
[`Future`]: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html
6673
[`Iterable`]: https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html
6774
[`Iterables.elementsEqual`]: https://guava.dev/releases/snapshot/api/docs/com/google/common/collect/Iterables.html#elementsEqual-java.lang.Iterable-java.lang.Iterable-
6875
[`LinkedList`]: https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html

0 commit comments

Comments
 (0)