Permalink
Switch branches/tags
Commits on Dec 4, 2016
  1. KAFKA-4205; KafkaApis: fix NPE caused by conversion to array

    ataraxer authored and guozhangwang committed Dec 4, 2016
    NPE was caused by `log.logSegments.toArray` resulting in array containing `null` values. The exact reason still remains somewhat a mystery to me, but it seems that the culprit is `JavaConverters` in combination with concurrent data structure access.
    
    Here's a simple code example to prove that:
    ```scala
    import java.util.concurrent.ConcurrentSkipListMap
    // Same as `JavaConversions`, but allows explicit conversions via `asScala`/`asJava` methods.
    import scala.collection.JavaConverters._
    
    case object Value
    val m = new ConcurrentSkipListMap[Int, Value.type]
    new Thread { override def run() = { while (true) m.put(9000, Value) } }.start()
    new Thread { override def run() = { while (true) m.remove(9000) } }.start()
    new Thread { override def run() = { while (true) { println(m.values.asScala.toArray.headOption) } } }.start()
    ```
    
    Running the example will occasionally print `Some(null)` indicating that there's something shady going on during `toArray` conversion.
    
    `null`s magically disappear by making the following change:
    ```diff
    - println(m.values.asScala.toArray.headOption)
    + println(m.values.asScala.toSeq.headOption)
    ```
    
    Author: Anton Karamanov <ataraxer@yandex-team.ru>
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>, Guozhang Wang <wangguoz@gmail.com>
    
    Closes #2204 from ataraxer/KAFKA-4205
Commits on Oct 8, 2014
  1. kafka-1644; Inherit FetchResponse from RequestOrResponse; patched by …

    ataraxer authored and junrao committed Oct 8, 2014
    …Anton Karamanov; reviewed by Jun Rao
Commits on Sep 17, 2014
  1. kafka-1620; Make kafka api protocol implementation public; patched by…

    ataraxer authored and junrao committed Sep 17, 2014
    … Anton Karamanov; reviewed by Jun Rao
Commits on Jul 28, 2014
  1. kafka-1414; Speedup broker startup after hard reset; patched by Anton…

    ataraxer authored and junrao committed Jul 28, 2014
    … Karamanov; reviewed by Jay Kreps and Jun Rao