kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nehanarkh...@apache.org
Subject git commit: KAFKA-771 NPE in handleOffsetCommitRequest; reviewed by Neha Narkhede
Date Mon, 25 Feb 2013 02:10:38 GMT
Updated Branches:
  refs/heads/trunk e7edb5e1e -> 218e6a53c


KAFKA-771 NPE in handleOffsetCommitRequest; reviewed by Neha Narkhede


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

Branch: refs/heads/trunk
Commit: 218e6a53c1385be897d9f8a3a39baa38b68d7992
Parents: e7edb5e
Author: David Arthur <mumrah@gmail.com>
Authored: Sun Feb 24 18:10:21 2013 -0800
Committer: Neha Narkhede <neha.narkhede@gmail.com>
Committed: Sun Feb 24 18:10:29 2013 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/server/KafkaApis.scala   |    2 +-
 .../scala/unit/kafka/server/OffsetCommitTest.scala |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/218e6a53/core/src/main/scala/kafka/server/KafkaApis.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/server/KafkaApis.scala b/core/src/main/scala/kafka/server/KafkaApis.scala
index 9b97ca6..c059981 100644
--- a/core/src/main/scala/kafka/server/KafkaApis.scala
+++ b/core/src/main/scala/kafka/server/KafkaApis.scala
@@ -476,7 +476,7 @@ class KafkaApis(val requestChannel: RequestChannel,
     val responseInfo = offsetCommitRequest.requestInfo.map( t => {
       val topicDirs = new ZKGroupTopicDirs(offsetCommitRequest.groupId, t._1.topic)
       try {
-        if(t._2.metadata.length > config.offsetMetadataMaxSize) {
+        if(t._2.metadata != null && t._2.metadata.length > config.offsetMetadataMaxSize)
{
           (t._1, ErrorMapping.OffsetMetadataTooLargeCode)
         } else {
           ZkUtils.updatePersistentPath(zkClient, topicDirs.consumerOffsetDir + "/" +

http://git-wip-us.apache.org/repos/asf/kafka/blob/218e6a53/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala b/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
index 48d5647..6989c95 100644
--- a/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
+++ b/core/src/test/scala/unit/kafka/server/OffsetCommitTest.scala
@@ -171,4 +171,14 @@ class OffsetCommitTest extends JUnit3Suite with ZooKeeperTestHarness
{
 
   }
 
+  @Test
+  def testNullMetadata() {
+    val topicAndPartition = TopicAndPartition("null-metadata", 0)
+    val commitRequest = OffsetCommitRequest("test-group", Map(topicAndPartition -> OffsetMetadataAndError(
+      offset=42L,
+      metadata=null
+    )))
+    val commitResponse = simpleConsumer.commitOffsets(commitRequest)
+    assertEquals(ErrorMapping.NoError, commitResponse.requestInfo.get(topicAndPartition).get)
+  }
 }


Mime
View raw message