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

    https://github.com/apache/spark/pull/18143#discussion_r119085683
  
    --- Diff: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/CachedKafkaConsumer.scala
 ---
    @@ -383,19 +362,16 @@ private[kafka010] object CachedKafkaConsumer extends 
Logging {
         // If this is reattempt at running the task, then invalidate cache and 
start with
         // a new consumer
         if (TaskContext.get != null && TaskContext.get.attemptNumber >= 1) {
    -      removeKafkaConsumer(topic, partition, kafkaParams)
    -      val consumer = new CachedKafkaConsumer(topicPartition, kafkaParams)
    -      consumer.inuse = true
    -      cache.put(key, consumer)
    -      consumer
    -    } else {
    -      if (!cache.containsKey(key)) {
    -        cache.put(key, new CachedKafkaConsumer(topicPartition, 
kafkaParams))
    -      }
    -      val consumer = cache.get(key)
    -      consumer.inuse = true
    -      consumer
    +      cache.invalidate(key)
         }
    +
    +    val consumer = cache.get(key, new Callable[CachedKafkaConsumer] {
    --- End diff --
    
    AFAIK, this is possible scala 2.12 onwards. 
[reference](http://www.scala-lang.org/news/2.12.0#lambda-syntax-for-sam-types)


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to