Skip to content

Commit

Permalink
Use Http2Headers.size() instead of isEmpty() (#13717)
Browse files Browse the repository at this point in the history
Motivation:

grpc-java prior to version 1.59.1 does not implement
`Http2Headers.isEmpty()` method (it throws
`UnsupportedOperationException`). While the fix was released in 1.59.1,
there is another issue with circular dependencies between `grpc-core`
and `grpc-util` modules. To unblock Netty users that also depend on
grpc-java, we can check the size.

Modifications:

- Use `Http2Headers.size()` instead of `Http2Headers.isEmpty()` in
`DefaultHttp2ConnectionDecoder`;

Result:

Users of older grpc-java versions can independently bump Netty version.
  • Loading branch information
idelpivnitskiy committed Dec 5, 2023
1 parent bd12689 commit 8b20d6b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers
"Multiple content-length headers received");
}
}
} else if (validateHeaders && !headers.isEmpty()) {
// Use size() instead of isEmpty() for backward compatibility with grpc-java prior to 1.59.1,
// see https://github.com/grpc/grpc-java/issues/10665
} else if (validateHeaders && headers.size() > 0) {
// Need to check trailers don't contain pseudo headers. According to RFC 9113
// Trailers MUST NOT include pseudo-header fields (Section 8.3).
for (Iterator<Entry<CharSequence, CharSequence>> iterator =
Expand Down

0 comments on commit 8b20d6b

Please sign in to comment.