kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-4031; Check if buffer cleaner is null before using it
Date Fri, 12 Aug 2016 11:07:44 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 68b5d014f -> 39431f734


KAFKA-4031; Check if buffer cleaner is null before using it

A small fix to check null before using the reference

Author: Som Sahu <sosahu@microsoft.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #1718 from soumyajit-sahu/nullCheckForDirectBufferCleaner


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/39431f73
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/39431f73
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/39431f73

Branch: refs/heads/trunk
Commit: 39431f7347d994f18878d199cc268ee7cdcf063d
Parents: 68b5d01
Author: Som Sahu <sosahu@microsoft.com>
Authored: Fri Aug 12 12:06:58 2016 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Fri Aug 12 12:06:58 2016 +0100

----------------------------------------------------------------------
 core/src/main/scala/kafka/log/OffsetIndex.scala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/39431f73/core/src/main/scala/kafka/log/OffsetIndex.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/log/OffsetIndex.scala b/core/src/main/scala/kafka/log/OffsetIndex.scala
index f432732..848fe3b 100755
--- a/core/src/main/scala/kafka/log/OffsetIndex.scala
+++ b/core/src/main/scala/kafka/log/OffsetIndex.scala
@@ -309,7 +309,11 @@ class OffsetIndex(@volatile private[this] var _file: File, val baseOffset:
Long,
   private def forceUnmap(m: MappedByteBuffer) {
     try {
       m match {
-        case buffer: DirectBuffer => buffer.cleaner().clean()
+        case buffer: DirectBuffer =>
+          val bufferCleaner = buffer.cleaner()
+          /* cleaner can be null if the mapped region has size 0 */
+          if (bufferCleaner != null)
+            bufferCleaner.clean()
         case _ =>
       }
     } catch {


Mime
View raw message