Source:
public boolean commitOffset() { final int correlationId = m_topicAndPartition.partition(); final short version = 1; final short notCoordinatorCode = ErrorMapping.NotCoordinatorForConsumerCode(); final long safe = m_gapTracker.commit(-1L); if (safe > m_lastCommittedOffset) { OffsetCommitRequest offsetCommitRequest = new OffsetCommitRequest( m_config.getGroupId(), singletonMap(m_topicAndPartition, new OffsetAndMetadata(safe, "commit", ErrorMapping.NoError())), correlationId, KafkaStreamImporterConfig.CLIENT_ID, version ); OffsetCommitResponse offsetCommitResponse = null; try { SimpleConsumer consumer = null;; int retries = 3; short code = notCoordinatorCode; while ((consumer == null || code == notCoordinatorCode) && --retries >= 0) { if ((consumer = m_offsetManager.get()) == null) { getOffsetCoordinator(); rateLimitedLog(Level.ERROR, null, "Commit Offset Failed to get offset coordinator for " + m_topicAndPartition); continue; } offsetCommitResponse = consumer.commitOffsets(offsetCommitRequest); code = ((Short) offsetCommitResponse.errors().get(m_topicAndPartition)); if (code == notCoordinatorCode) { info(null, "Not coordinator for committing offset for " + m_topicAndPartition + " Updating coordinator."); getOffsetCoordinator(); continue; } } if (retries < 0 || offsetCommitResponse == null) { return false; } } catch (Exception e) { rateLimitedLog(Level.ERROR, e, "Failed to commit Offset for " + m_topicAndPartition); return false; } final short code = ((Short) offsetCommitResponse.errors().get(m_topicAndPartition)); if (code != ErrorMapping.NoError()) { final String msg = "Commit Offset Failed to commit for " + m_topicAndPartition; rateLimitedLog(Level.ERROR, ErrorMapping.exceptionFor(code), msg); return false; } m_lastCommittedOffset = safe; } return true; }

Target:
public boolean commitOffset() { final int correlationId = m_topicAndPartition.partition(); final short version = 1; final long safe = m_gapTracker.commit(-1L); if (safe > m_lastCommittedOffset) { long now = System.currentTimeMillis(); OffsetCommitRequest offsetCommitRequest = new OffsetCommitRequest( m_config.getGroupId(), singletonMap(m_topicAndPartition, new OffsetAndMetadata(safe, "commit", now)), correlationId, KafkaStreamImporterConfig.CLIENT_ID, version ); OffsetCommitResponse offsetCommitResponse = null; try { BlockingChannel channel = null; int retries = 3; while (channel == null && --retries >= 0) { if ((channel = m_offsetManager.get()) == null) { getOffsetCoordinator(); rateLimitedLog(Level.ERROR, null, "Commit Offset Failed to get offset coordinator for " + m_topicAndPartition); continue; } channel.send(offsetCommitRequest.underlying()); offsetCommitResponse = OffsetCommitResponse.readFrom(channel.receive().buffer()); final short code = ((Short) offsetCommitResponse.errors().get(m_topicAndPartition)); if (code == ErrorMapping.NotCoordinatorForConsumerCode() || code == ErrorMapping.ConsumerCoordinatorNotAvailableCode()) { info(null, "Not coordinator for committing offset for " + m_topicAndPartition + " Updating coordinator."); getOffsetCoordinator(); channel = null; continue; } } if (retries < 0 || offsetCommitResponse == null) { return false; } } catch (Exception e) { rateLimitedLog(Level.ERROR, e, "Failed to commit Offset for " + m_topicAndPartition); if (e instanceof IOException) { getOffsetCoordinator(); } return false; } final short code = ((Short) offsetCommitResponse.errors().get(m_topicAndPartition)); if (code != ErrorMapping.NoError()) { final String msg = "Commit Offset Failed to commit for " + m_topicAndPartition; rateLimitedLog(Level.ERROR, ErrorMapping.exceptionFor(code), msg); return false; } m_lastCommittedOffset = safe; } return true; }