Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/1437#discussion_r46839322
--- Diff:
flink-streaming-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumer.java
---
@@ -640,30 +642,38 @@ public PeriodicOffsetCommitter(long commitInterval,
FlinkKafkaConsumer consumer)
@Override
public void run() {
try {
+
while (running) {
try {
Thread.sleep(commitInterval);
// ------------ commit
current offsets ----------------
// create copy of current
offsets
- long[] currentOffsets =
Arrays.copyOf(consumer.lastOffsets, consumer.lastOffsets.length);
-
- Map<TopicPartition, Long>
offsetsToCommit = new HashMap<>();
- for (TopicPartition tp :
(List<TopicPartition>)consumer.subscribedPartitions) {
- int partition =
tp.partition();
- long offset =
currentOffsets[partition];
- long lastCommitted =
consumer.commitedOffsets[partition];
-
+ HashMap<KafkaTopicPartition,
Long> currentOffsets = (HashMap<KafkaTopicPartition, Long>)
consumer.lastOffsets.clone();
+
+ Map<KafkaTopicPartition, Long>
offsetsToCommit = new HashMap<>();
+ for (KafkaTopicPartition tp :
(List<KafkaTopicPartition>)consumer.subscribedPartitions) {
--- End diff --
A bit unclean to cast here from `List<KafkaTopicPartitionLeader>` to
`List<KafkaTopicPartition>`. Why not simply iterate with the
`KafkaTopicPartitionLeader` type?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---