haroon3rd opened a new pull request, #1476: URL: https://github.com/apache/ratis/pull/1476
## What changes were proposed in this pull request? This patch fixes an issue in the membership example where the `query` command displayed an empty counter value even after successful counter updates. The root cause was an encoding mismatch between the server and client implementations. The `CounterStateMachine` returns the counter value as a 4-byte binary integer (`ByteString`), while the membership example client attempted to decode the response using UTF-8 string conversion. As a result, the query output appeared empty. This patch updates the `queryCounter()` implementation in `RaftCluster` to correctly deserialize the binary response using `ByteBuffer.getInt()`, allowing the current counter value to be displayed correctly. ## What is the link to the Apache JIRA Apache JIRA: RATIS-XXXX (Replace with the actual JIRA issue link after creating the issue.) ## How was this patch tested? The fix was verified manually using the Ratis membership example. Test procedure: 1. Build and run the membership example. 2. Start a cluster with multiple peers. 3. Execute the `incr` command multiple times. 4. Execute the `query` command. Before the fix: ```text >>> incr >>> incr >>> query Current counter value: ``` After the fix: ```text >>> incr >>> incr >>> query Current counter value: 2 ``` The returned counter value now correctly reflects the state maintained by `CounterStateMachine`. -- 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]
