You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Tsz-wo Sze (Jira)" <ji...@apache.org> on 2026/09/21 16:02:00 UTC
[jira] [Commented] (RATIS-2711) Double position counting in LimitedInputStream
[ https://issues.apache.org/jira/browse/RATIS-2711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18117798#comment-18117798 ]
Tsz-wo Sze commented on RATIS-2711:
-----------------------------------
[~lugency], thanks for filing this JIRA and providing tests. Would you also like to submit a pull request fixing the bugs?
> Double position counting in LimitedInputStream
> ----------------------------------------------
>
> Key: RATIS-2711
> URL: https://issues.apache.org/jira/browse/RATIS-2711
> Project: Ratis
> Issue Type: Bug
> Components: RaftLog
> Reporter: Guangcun Li
> Priority: Major
> Attachments: RATIS-2711_test.patch
>
>
> h3. 1. Double counting in LimitedInputStream.read(byte[])
> {{super.read(byte[])}} delegates to {{read(byte[], int, int)}}, which already updates {{curPos}}. The outer method increments it again.
> Remove the redundant {{read(byte[])}} override. The current {{SegmentedRaftLogReader}} avoids this bug because its {{DataInputStream}} wrapper calls the three-argument overload directly.
> h3. 2. Redundant assignment in BufferedWriteChannel.flushBuffer()
> Since RATIS-589, {{flushBuffer()}} calls {{writeToChannel()}}, which already sets {{forced = false}}. The subsequent assignment can be removed.
> h3. Verification
> * A reproducing test confirms the double counting.
> * {{TestBufferedWriteChannel}} passes with the redundant assignment replaced by an assertion that {{forced}} is already {{false}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)