sven-lange-last commented on a change in pull request #3921: Synchronize access to the KafkaConsumer. URL: https://github.com/apache/incubator-openwhisk/pull/3921#discussion_r207787705
########## File path: common/scala/src/main/scala/whisk/connector/kafka/KafkaConsumerConnector.scala ########## @@ -182,10 +185,11 @@ class KafkaConsumerConnector( blocking { if (offset > 0) { val topicAndPartition = new TopicPartition(topic, 0) - consumer.endOffsets(Set(topicAndPartition).asJava).asScala.get(topicAndPartition).foreach { endOffset => - // endOffset could lag behind the offset reported by the consumer internally resulting in negative numbers - val queueSize = (endOffset - offset).max(0) - MetricEmitter.emitHistogramMetric(queueMetric, queueSize) + synchronized(consumer.endOffsets(Set(topicAndPartition).asJava)).asScala.get(topicAndPartition).foreach { Review comment: This line also puzzled me at the first sight. If you expand the section of compared lines in this diff view, you will see that the `synchronized` in line 159 belongs to method `recreateConsumer()` while the `synchronized` you commented on in line 188 belongs to a totally different scope in the scheduled task. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services