chennaji9 opened a new pull request, #11296: URL: https://github.com/apache/rocketmq/pull/11296
<!-- Please make sure the target branch is right. In most case, the target branch should be `develop`. --> ### Which Issue(s) This PR Fixes Fixes #11283 ### Brief Description `RpcClientUtils.encodeBody` used `mark()`/`get()`/`reset()` on the caller's `ByteBuffer`. That restores the buffer's `position` but **overwrites whatever mark the caller had previously set**, so a later `reset()` by the caller jumps to the wrong position — encoding a body had an observable side effect beyond reading it. The ByteBuffer branch now reads the remaining bytes from `buffer.duplicate()` and never touches the original buffer's position, limit or mark. Adds `RpcClientUtilsTest` (JUnit 4 + AssertJ, same package) with 5 tests: caller-mark/position preservation across `encodeBody`, remaining-bytes read, read-only buffer, `null` → `null`, and byte-array passthrough. ### How Did You Test This Change? - `mvn -B -pl remoting -am -Dtest=RpcClientUtilsTest -Dsurefire.failIfNoSpecifiedTests=false test` → BUILD SUCCESS, `Tests run: 5, Failures: 0, Errors: 0, Skipped: 0`. - Regression proof: with the pre-fix `mark()/reset()` code temporarily restored, the new mark test fails with exactly the issue's symptom (`expected: 1 but was: 3` at the `reset()` assertion); green again with the fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
