Skip to content

Commit

Permalink
Fix issue: grpc-previous-rpc-attempts not added to initial response m…
Browse files Browse the repository at this point in the history
…etadata
  • Loading branch information
pandaapo committed Nov 10, 2022
1 parent eb1e5a1 commit 356626c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/io/grpc/internal/RetriableStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ final Metadata updateHeaders(
Metadata originalHeaders, int previousAttemptCount) {
Metadata newHeaders = new Metadata();
newHeaders.merge(originalHeaders);
if (previousAttemptCount > 0) {
if (previousAttemptCount >= 0) {
newHeaders.put(GRPC_PREVIOUS_RPC_ATTEMPTS, String.valueOf(previousAttemptCount));
}
return newHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ public void updateHeaders() {
Metadata originalHeaders = new Metadata();
Metadata headers = retriableStream.updateHeaders(originalHeaders, 0);
assertNotSame(originalHeaders, headers);
assertNull(headers.get(GRPC_PREVIOUS_RPC_ATTEMPTS));
assertEquals("0", headers.get(GRPC_PREVIOUS_RPC_ATTEMPTS));

headers = retriableStream.updateHeaders(originalHeaders, 345);
assertEquals("345", headers.get(GRPC_PREVIOUS_RPC_ATTEMPTS));
Expand Down

0 comments on commit 356626c

Please sign in to comment.