[Bug] Http2ProtocolProxyHandler.match throws on short ByteBuf
- Dominant language
- Java
- Stars
- 22.6k
- Forks
- 12k
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 27
Description
### Before Creating the Bug Report
- [x] 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.
Contributor guide
Research direction
Start at Http2ProtocolProxyHandler.match(ByteBuf in) and inspect the readable-byte handling before the HTTP/2 PRI prefix comparison. Reproduce the behavior with empty and fewer-than-four-byte ByteBuf inputs; done means match returns false without IndexOutOfBoundsException while normal prefix detection still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, java
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100