-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
StatusOr
has been introduced in #11330
The implemented equals() method tries to compare value or status.
However, Status.equals()
intentionally does not compare its fields.
grpc-java/api/src/main/java/io/grpc/Status.java
Lines 654 to 660 in ca4819a
* Equality on Statuses is not well defined. Instead, do comparison based on their Code with | |
* {@link #getCode}. The description and cause of the Status are unlikely to be stable, and | |
* additional fields may be added to Status in the future. | |
*/ | |
@Override | |
public boolean equals(Object obj) { | |
return super.equals(obj); |
The corresponding StatusOr test compares same Status instance and passes
grpc-java/api/src/test/java/io/grpc/StatusOrTest.java
Lines 62 to 63 in ca4819a
public void equals_sameStatuses() { | |
assertThat(StatusOr.fromStatus(Status.ABORTED)).isEqualTo(StatusOr.fromStatus(Status.ABORTED)); |
but would fail if there is a description
String msg = "1";
assertThat(StatusOr.fromStatus(Status.ABORTED.withDescription(msg)))
.isEqualTo(StatusOr.fromStatus(Status.ABORTED.withDescription(msg)));
Metadata
Metadata
Assignees
Labels
No labels