[ 
https://issues.apache.org/jira/browse/KAFKA-9686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17054869#comment-17054869
 ] 

ASF GitHub Bot commented on KAFKA-9686:
---------------------------------------

chia7712 commented on pull request #8255: KAFKA-9686 MockConsumer#endOffsets 
should be idempotent
URL: https://github.com/apache/kafka/pull/8255
 
 
   ```scala
       private Long getEndOffset(List<Long> offsets) {
           if (offsets == null || offsets.isEmpty()) {
               return null;
           }
           return offsets.size() > 1 ? offsets.remove(0) : offsets.get(0);
       }
   ```
   The above code has two issues.
   1. It does not return the latest offset since the latest offset is at the 
end of offsets
   1. It removes the element from offsets so MockConsumer#endOffsets gets 
non-idempotent
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> MockConsumer#endOffsets should be idempotent
> --------------------------------------------
>
>                 Key: KAFKA-9686
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9686
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Chia-Ping Tsai
>            Assignee: Chia-Ping Tsai
>            Priority: Major
>
> {code:java}
>     private Long getEndOffset(List<Long> offsets) {
>         if (offsets == null || offsets.isEmpty()) {
>             return null;
>         }
>         return offsets.size() > 1 ? offsets.remove(0) : offsets.get(0);
>     }
> {code}
> The above code has two issues.
> 1. It does not return the latest offset since the latest offset is at the end 
> of offsets
> 1. It removes the element from offsets so MockConsumer#endOffsets gets 
> non-idempotent



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to