Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.netty:netty-codec-http2 4.1.101.Final causes failure when used with io.grpc:grpc-netty 1.59.0 #13710

Closed
runenielsen opened this issue Nov 30, 2023 · 2 comments

Comments

@runenielsen
Copy link

runenielsen commented Nov 30, 2023

Expected behavior

No failure, when calling a GRPC service.

Actual behavior

This failure, when calling a GRPC service:

io.grpc.StatusException: UNKNOWN
	at io.grpc.Status.asException(Status.java:552)
	at io.grpc.kotlin.ClientCalls$rpcImpl$1$1$1.onClose(ClientCalls.kt:300)
	at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574)
	at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72)
	at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742)
	at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.UnsupportedOperationException
	at io.grpc.netty.AbstractHttp2Headers.isEmpty(AbstractHttp2Headers.java:40)
	at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onHeadersRead(DefaultHttp2ConnectionDecoder.java:419)
	at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onHeadersRead(DefaultHttp2ConnectionDecoder.java:352)
...

These lines are new in DefaultHttp2ConnectionDecoder in version 101 compared to 100 and cause the error:

            } else if (validateHeaders && !headers.isEmpty()) {
                // 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 =
                    headers.iterator(); iterator.hasNext();) {
                    CharSequence name = iterator.next().getKey();
                    if (Http2Headers.PseudoHeaderName.hasPseudoHeaderFormat(name)) {
                        throw streamError(stream.id(), PROTOCOL_ERROR,
                                "Found invalid Pseudo-Header in trailers: %s", name);
                    }
                }
            }

... the reason is that it calls !headers.isEmpty(), which looks like this in AbstractHttp2Headers in grpc-netty:

  @Override
  public boolean isEmpty() {
    throw new UnsupportedOperationException();
  }

Steps to reproduce

  1. Clone https://github.com/runenielsen/netty-grpc-bug
  2. Run the test NettyGrpcBugTest and see it fails
  3. In build.gradle.kts comment in the 4 lines under // TODO: Comment in to see test working with old version.
  4. Run the test NettyGrpcBugTest and see it now works

Minimal yet complete reproducer code (or URL to code)

https://github.com/runenielsen/netty-grpc-bug

Netty version

4.1.101.Final

JVM version (e.g. java -version)

openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode)

OS version (e.g. uname -a)

Darwin Xyz-MacBook-Pro.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020 arm64
@slandelle
Copy link
Contributor

That's a grpc issue and it's already been fixed, see grpc/grpc-java#10665

@slandelle slandelle closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@runenielsen
Copy link
Author

@slandelle : Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants