kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [kafka] branch trunk updated: HOTFIX: Fix infinite loop in AbstractIndex.indexSlotRangeFor (#7702)
Date Sun, 17 Nov 2019 18:08:57 GMT
This is an automated email from the ASF dual-hosted git repository.

ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ca7a5ea  HOTFIX: Fix infinite loop in AbstractIndex.indexSlotRangeFor (#7702)
ca7a5ea is described below

commit ca7a5eae890fd92cb9794ee0923d424a7e680d61
Author: Jason Gustafson <jason@confluent.io>
AuthorDate: Sun Nov 17 10:08:29 2019 -0800

    HOTFIX: Fix infinite loop in AbstractIndex.indexSlotRangeFor (#7702)
    
    Fixes regression from #5378 which causing an infinite loop in `binarySearch`.
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>
---
 core/src/main/scala/kafka/log/AbstractIndex.scala | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/core/src/main/scala/kafka/log/AbstractIndex.scala b/core/src/main/scala/kafka/log/AbstractIndex.scala
index 71887f1..8e70ae1 100644
--- a/core/src/main/scala/kafka/log/AbstractIndex.scala
+++ b/core/src/main/scala/kafka/log/AbstractIndex.scala
@@ -29,8 +29,6 @@ import kafka.utils.CoreUtils.inLock
 import kafka.utils.{CoreUtils, Logging}
 import org.apache.kafka.common.utils.{ByteBufferUnmapper, OperatingSystem, Utils}
 
-import scala.math.ceil
-
 /**
  * The abstract index class which holds entry format agnostic methods.
  *
@@ -377,7 +375,7 @@ abstract class AbstractIndex[K, V](@volatile var file: File, val baseOffset:
Lon
       var lo = begin
       var hi = end
       while(lo < hi) {
-        val mid = (lo + hi) >>> 1
+        val mid = (lo + hi + 1) >>> 1
         val found = parseEntry(idx, mid)
         val compareResult = compareIndexEntry(found, target, searchEntity)
         if(compareResult > 0)


Mime
View raw message