Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/main/java/io/grpc/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private static List<Status> buildStatusList() {
* Return a {@link Status} given a canonical error {@link Code} value.
*/
public static Status fromCodeValue(int codeValue) {
if (codeValue < 0 || codeValue > STATUS_LIST.size()) {
if (codeValue < 0 || codeValue >= STATUS_LIST.size()) {
return UNKNOWN.withDescription("Unknown code " + codeValue);
} else {
return STATUS_LIST.get(codeValue);
Expand Down
1 change: 1 addition & 0 deletions api/src/test/java/io/grpc/StatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void verifyExceptionMessage() {
@Test
public void impossibleCodeValue() {
assertEquals(Code.UNKNOWN, Status.fromCodeValue(-1).getCode());
assertEquals(Code.UNKNOWN, Status.fromCodeValue(17).getCode());
}

@Test
Expand Down