Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1437#discussion_r46837508
  
    --- Diff: 
flink-streaming-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumer.java
 ---
    @@ -563,37 +559,44 @@ public void notifyCheckpointComplete(long 
checkpointId) throws Exception {
                                        LOG.warn("Received confirmation for 
unknown checkpoint id {}", checkpointId);
                                        return;
                                }
    -   
    -                           checkpointOffsets = (long[]) 
pendingCheckpoints.remove(posInMap);
    +
    +                           //noinspection unchecked
    +                           checkpointOffsets = 
(HashMap<KafkaTopicPartition, Long>) pendingCheckpoints.remove(posInMap);
    +
                                
                                // remove older checkpoints in map
                                for (int i = 0; i < posInMap; i++) {
                                        pendingCheckpoints.remove(0);
                                }
                        }
    -   
    -                   if (LOG.isInfoEnabled()) {
    -                           LOG.info("Committing offsets {} to offset 
store: {}", Arrays.toString(checkpointOffsets), offsetStore);
    +                   if(checkpointOffsets.size() == 0) {
    +                           LOG.info("Checkpoint state was empty.");
    +                           return;
                        }
        
                        // build the map of (topic,partition) -> committed 
offset
    -                   Map<TopicPartition, Long> offsetsToCommit = new 
HashMap<>();
    -                   for (TopicPartition tp : subscribedPartitions) {
    -                           
    -                           int partition = tp.partition();
    -                           long offset = checkpointOffsets[partition];
    -                           long lastCommitted = commitedOffsets[partition];
    -                           
    +                   Map<KafkaTopicPartition, Long> offsetsToCommit = new 
HashMap<>();
    +                   for (KafkaTopicPartition tp : subscribedPartitions) {
    +                           Long offset = checkpointOffsets.get(tp);
    +                           Long lastCommitted = commitedOffsets.get(tp);
    +                           if(lastCommitted == null) {
    +                                   lastCommitted = OFFSET_NOT_SET;
    +                           }
                                if (offset != OFFSET_NOT_SET) {
                                        if (offset > lastCommitted) {
                                                offsetsToCommit.put(tp, offset);
    -                                           LOG.debug("Committing offset {} 
for partition {}", offset, partition);
    +                                           //noinspection unchecked
    --- End diff --
    
    Inspection suppression should not be needed...


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

Reply via email to