kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject kafka git commit: KAFKA-4483; Fix NPE in `Log` constructor if log level is INFO or finer
Date Sat, 03 Dec 2016 04:11:37 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk b06fc322b -> e43bbce49


KAFKA-4483; Fix NPE in `Log` constructor if log level is INFO or finer

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

Reviewers: Jason Gustafson <jason@confluent.io>

Closes #2207 from ijuma/kafka-4483-npe-in-log-constructor


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

Branch: refs/heads/trunk
Commit: e43bbce493192ea5f936867e8cdae163ab850650
Parents: b06fc32
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Fri Dec 2 20:09:33 2016 -0800
Committer: Jason Gustafson <jason@confluent.io>
Committed: Fri Dec 2 20:09:33 2016 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/log/Log.scala | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/e43bbce4/core/src/main/scala/kafka/log/Log.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/log/Log.scala b/core/src/main/scala/kafka/log/Log.scala
index 24177d1..122f8be 100644
--- a/core/src/main/scala/kafka/log/Log.scala
+++ b/core/src/main/scala/kafka/log/Log.scala
@@ -104,19 +104,22 @@ class Log(@volatile var dir: File,
       0
   }
 
+  @volatile private var nextOffsetMetadata: LogOffsetMetadata = _
+
   /* the actual segments of the log */
   private val segments: ConcurrentNavigableMap[java.lang.Long, LogSegment] = new ConcurrentSkipListMap[java.lang.Long,
LogSegment]
   locally {
     val startMs = time.milliseconds
+
     loadSegments()
+    /* Calculate the offset of the next message */
+    nextOffsetMetadata = new LogOffsetMetadata(activeSegment.nextOffset(), activeSegment.baseOffset,
+      activeSegment.size.toInt)
+
     info("Completed load of log %s with %d log segments and log end offset %d in %d ms"
       .format(name, segments.size(), logEndOffset, time.milliseconds - startMs))
   }
 
-  /* Calculate the offset of the next message */
-  @volatile private var nextOffsetMetadata = new LogOffsetMetadata(activeSegment.nextOffset(),
activeSegment.baseOffset,
-    activeSegment.size.toInt)
-
   val topicAndPartition: TopicAndPartition = Log.parseTopicPartitionName(dir)
 
   private val tags = Map("topic" -> topicAndPartition.topic, "partition" -> topicAndPartition.partition.toString)


Mime
View raw message