[ 
https://issues.apache.org/jira/browse/RATIS-2228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Song Ziyang resolved RATIS-2228.
--------------------------------
    Resolution: Fixed

The PR is now merged. [~szetszwo], thanks for cleaning up the code!

> Refactor the offered map in LogAppenderBase.nextAppendEntriesRequest
> --------------------------------------------------------------------
>
>                 Key: RATIS-2228
>                 URL: https://issues.apache.org/jira/browse/RATIS-2228
>             Project: Ratis
>          Issue Type: Sub-task
>          Components: server
>            Reporter: Tsz-wo Sze
>            Assignee: Tsz-wo Sze
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> -In LogAppenderBase.nextAppendEntriesRequest,-
>  # -it reads N entries from RaftLog and offers them to the buffer queue.-
>  # -Then, it pulls M protos from the buffer queue.-
>  # -Finally, it returns a ReferenceCountedObject using the N offered entries 
> and the M pulled protos.-
> -The problem is that M and N could be unequal.-
> Actually, there is no problem since the finally-block below will clean up the 
> remaining entries.
> {code}
>     } finally {
>       for (EntryWithData entry : buffer) {
>         // Release remaining entries.
>         
> Optional.ofNullable(offered.remove(entry.getIndex())).ifPresent(ReferenceCountedObject::release);
>       }
>       buffer.clear();
>     }
> {code}
> Let's take this opportunity to clean up the code.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to