You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Chia-Ping Tsai (Jira)" <ji...@apache.org> on 2020/03/09 11:36:00 UTC

[jira] [Updated] (KAFKA-9686) MockConsumer#endOffsets should be idempotent

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

Chia-Ping Tsai updated KAFKA-9686:
----------------------------------
    Description: 

{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


  was:
```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



> 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)