Source:
private void possiblyResetOffsetsOrWait( Map<TopicPartition, Long> outOfRangePartitions, RecordSupplier<Integer, Long> recordSupplier, TaskToolbox taskToolbox ) throws InterruptedException, IOException { final Map<TopicPartition, Long> resetPartitions = new HashMap<>(); boolean doReset = false; if (tuningConfig.isResetOffsetAutomatically()) { for (Map.Entry<TopicPartition, Long> outOfRangePartition : outOfRangePartitions.entrySet()) { final TopicPartition topicPartition = outOfRangePartition.getKey(); final long nextOffset = outOfRangePartition.getValue(); StreamPartition<Integer> streamPartition = StreamPartition.of( topicPartition.topic(), topicPartition.partition() ); recordSupplier.seekToEarliest(ImmutableSet.of(streamPartition)); final Long leastAvailableOffset = recordSupplier.getEarliestSequenceNumber(streamPartition); if (leastAvailableOffset == null) { throw new ISE( "got null sequence number for partition[%s] when fetching from kafka!", topicPartition.partition() ); } recordSupplier.seek(streamPartition, nextOffset); if (leastAvailableOffset > nextOffset) { doReset = true; resetPartitions.put(topicPartition, nextOffset); } } } if (doReset) { sendResetRequestAndWait(resetPartitions.entrySet() .stream() .collect(Collectors.toMap(x -> StreamPartition.of( x.getKey().topic(), x.getKey().partition() ), Map.Entry::getValue)), taskToolbox); } else { log.warn("Retrying in %dms", task.getPollRetryMs()); pollRetryLock.lockInterruptibly(); try { long nanos = TimeUnit.MILLISECONDS.toNanos(task.getPollRetryMs()); while (nanos > 0L && !pauseRequested && !stopRequested.get()) { nanos = isAwaitingRetry.awaitNanos(nanos); } } finally { pollRetryLock.unlock(); } } }

Target:
private void possiblyResetOffsetsOrWait( Map<TopicPartition, Long> outOfRangePartitions, RecordSupplier<Integer, Long> recordSupplier, TaskToolbox taskToolbox ) throws InterruptedException, IOException { final Map<TopicPartition, Long> resetPartitions = new HashMap<>(); boolean doReset = false; if (task.getTuningConfig().isResetOffsetAutomatically()) { for (Map.Entry<TopicPartition, Long> outOfRangePartition : outOfRangePartitions.entrySet()) { final TopicPartition topicPartition = outOfRangePartition.getKey(); final long nextOffset = outOfRangePartition.getValue(); StreamPartition<Integer> streamPartition = StreamPartition.of( topicPartition.topic(), topicPartition.partition() ); final Long leastAvailableOffset = recordSupplier.getEarliestSequenceNumber(streamPartition); if (leastAvailableOffset == null) { throw new ISE( "got null sequence number for partition[%s] when fetching from kafka!", topicPartition.partition() ); } recordSupplier.seek(streamPartition, nextOffset); if (leastAvailableOffset > nextOffset) { doReset = true; resetPartitions.put(topicPartition, nextOffset); } } } if (doReset) { sendResetRequestAndWait(resetPartitions.entrySet() .stream() .collect(Collectors.toMap(x -> StreamPartition.of( x.getKey().topic(), x.getKey().partition() ), Map.Entry::getValue)), taskToolbox); } else { log.warn("Retrying in %dms", task.getPollRetryMs()); pollRetryLock.lockInterruptibly(); try { long nanos = TimeUnit.MILLISECONDS.toNanos(task.getPollRetryMs()); while (nanos > 0L && !pauseRequested && !stopRequested.get()) { nanos = isAwaitingRetry.awaitNanos(nanos); } } finally { pollRetryLock.unlock(); } } }