Before Creating the Bug Report
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
- Enable remoting local proxy gRPC protocol detection.
- Call
Http2ProtocolProxyHandler.match() with a ByteBuf containing fewer than 4 readable bytes.
- 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.
Before Creating the Bug Report
Runtime platform environment
N/A
RocketMQ version
develop branch
JDK Version
N/A
Describe the Bug
Http2ProtocolProxyHandler.match(ByteBuf in)callsin.getInt(in.readerIndex())directly after checkingenableRemotingLocalProxyGrpc.If the protocol detector receives an empty or short buffer with fewer than 4 readable bytes, Netty can throw
IndexOutOfBoundsExceptioninstead of returningfalseand letting the protocol detection pipeline wait for more data or reject the message safely.Steps to Reproduce
Http2ProtocolProxyHandler.match()with aByteBufcontaining fewer than 4 readable bytes.getInt(readerIndex)can throw because the handler does not checkreadableBytes()first.What Did You Expect to See?
Short buffers should not crash protocol detection.
match()should returnfalseuntil enough bytes are available to compare the HTTP/2PRIprefix.What Did You See Instead?
match()can throwIndexOutOfBoundsExceptionfor short buffers.Additional Context
This is in the Proxy remoting/gRPC ingress path and is a small runtime robustness fix.