Skip to content

[Bug] Http2ProtocolProxyHandler.match throws on short ByteBuf #10776

Description

@Aias00

Before Creating the Bug Report

  • I have searched the existing issues and pull requests.

Runtime platform environment

N/A

RocketMQ version

develop branch

JDK Version

N/A

Describe the Bug

Http2ProtocolProxyHandler.match(ByteBuf in) calls in.getInt(in.readerIndex()) directly after checking enableRemotingLocalProxyGrpc.

If the protocol detector receives an empty or short buffer with fewer than 4 readable bytes, Netty can throw IndexOutOfBoundsException instead of returning false and letting the protocol detection pipeline wait for more data or reject the message safely.

Steps to Reproduce

  1. Enable remoting local proxy gRPC protocol detection.
  2. Call Http2ProtocolProxyHandler.match() with a ByteBuf containing fewer than 4 readable bytes.
  3. Observe that getInt(readerIndex) can throw because the handler does not check readableBytes() first.

What Did You Expect to See?

Short buffers should not crash protocol detection. match() should return false until enough bytes are available to compare the HTTP/2 PRI prefix.

What Did You See Instead?

match() can throw IndexOutOfBoundsException for short buffers.

Additional Context

This is in the Proxy remoting/gRPC ingress path and is a small runtime robustness fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions