Source:
protected ConsumerRecords<?, ?> pollRecords(long pollInterval) throws Exception { ConsumerRecords<?, ?> records; try { long curPollTime = System.currentTimeMillis(); _lastPolledTimeMillis = curPollTime; records = _consumer.poll(pollInterval); long pollDurationMillis = System.currentTimeMillis() - curPollTime; if (pollDurationMillis > pollInterval + POLL_BUFFER_TIME_MILLIS) { _logger.warn("ConsumerId: {}, Kafka client poll took ms (> poll timeout + buffer time ms)", _taskName, pollDurationMillis, pollInterval, POLL_BUFFER_TIME_MILLIS); _consumerMetrics.updateClientPollOverTimeout(1); } _consumerMetrics.updateNumPolls(1); _consumerMetrics.updateEventCountsPerPoll(records.count()); if (!records.isEmpty()) { _consumerMetrics.updateEventsProcessedRate(records.count()); _consumerMetrics.updateLastEventReceivedTime(Instant.now()); } _pollAttempts = 0; _kafkaPositionTracker.ifPresent(tracker -> { for (final TopicPartition topicPartition : tracker.getPartitionsNeedingInit()) { try { tracker.initializePartition(topicPartition, _consumer.position(topicPartition)); } catch (IllegalStateException ignored) { } catch (InvalidOffsetException ignored) { } } tracker.onRecordsReceived(records, _consumer.metrics()); }); return records; } catch (NoOffsetForPartitionException e) { handleNoOffsetForPartitionException(e); return ConsumerRecords.EMPTY; } catch (WakeupException e) { _logger.warn("Got a WakeupException, shutdown in progress.", e); return ConsumerRecords.EMPTY; } catch (Exception e) { handlePollRecordsException(e); return ConsumerRecords.EMPTY; } }

Target:
protected ConsumerRecords<?, ?> pollRecords(long pollInterval) throws Exception { ConsumerRecords<?, ?> records; try { long curPollTime = System.currentTimeMillis(); _lastPolledTimeMillis = curPollTime; records = _consumer.poll(pollInterval); long pollDurationMillis = System.currentTimeMillis() - curPollTime; if (pollDurationMillis > pollInterval + POLL_BUFFER_TIME_MILLIS) { _logger.warn("ConsumerId: {}, Kafka client poll took ms (> poll timeout + buffer time ms)", _taskName, pollDurationMillis, pollInterval, POLL_BUFFER_TIME_MILLIS); _consumerMetrics.updateClientPollOverTimeout(1); } _consumerMetrics.updateNumPolls(1); _consumerMetrics.updateEventCountsPerPoll(records.count()); if (!records.isEmpty()) { _consumerMetrics.updateEventsProcessedRate(records.count()); _consumerMetrics.updateLastEventReceivedTime(Instant.now()); } _pollAttempts = 0; try { _kafkaPositionTracker.ifPresent(tracker -> { for (final TopicPartition topicPartition : tracker.getPartitionsNeedingInit()) { try { tracker.initializePartition(topicPartition, _consumer.position(topicPartition)); } catch (IllegalStateException e) { _logger.trace("Got IllegalStateException when processing partition {}", topicPartition, e); } catch (InvalidOffsetException e) { _logger.trace("Got InvalidOffsetException when processing partition {}", topicPartition, e); } } tracker.onRecordsReceived(records, _consumer.metrics()); }); } catch (WakeupException | InterruptException e) { throw e; } catch (Exception e) { _logger.warn("Got uncaught exception while processing position tracker code (swallowing and continuing)", e); } return records; } catch (NoOffsetForPartitionException e) { handleNoOffsetForPartitionException(e); return ConsumerRecords.EMPTY; } catch (WakeupException e) { _logger.warn("Got a WakeupException, shutdown in progress.", e); return ConsumerRecords.EMPTY; } catch (Exception e) { handlePollRecordsException(e); return ConsumerRecords.EMPTY; } }