Skip to content

Commit 7952afd

Browse files
Add some documentation to StatusOr.equals regarding how underlying statuses are compared, to avoid any confusion, as suggested in issue #11949. (#12036)
Add some documentation to StatusOr.equals regarding how underlying statuses are compared, to avoid any confusion, as suggested in issue #11949.
1 parent 6cd007d commit 7952afd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/src/main/java/io/grpc/StatusOr.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public Status getStatus() {
6666
return status == null ? Status.OK : status;
6767
}
6868

69+
/**
70+
* Note that StatusOr containing statuses, the equality comparision is delegated to
71+
* {@link Status#equals} which just does a reference equality check because equality on
72+
* Statuses is not well defined.
73+
* Instead, do comparison based on their Code with {@link Status#getCode}. The description and
74+
* cause of the Status are unlikely to be stable, and additional fields may be added to Status
75+
* in the future.
76+
*/
6977
@Override
7078
public boolean equals(Object other) {
7179
if (!(other instanceof StatusOr)) {

0 commit comments

Comments
 (0)