kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject kafka git commit: KAFKA-2972; Add missing `partitionsRemaingList.add` in `ControlledShutdownResponse` constructor
Date Wed, 09 Dec 2015 19:57:24 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 98ea82a89 -> 7bb7e415a


KAFKA-2972; Add missing `partitionsRemaingList.add` in `ControlledShutdownResponse` constructor

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

Reviewers: Grant Henke, Guozhang Wang

Closes #649 from ijuma/KAFKA-2972-controlled-shutdown-response-bug


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

Branch: refs/heads/trunk
Commit: 7bb7e415a371909757a6099a911587047d4c4b69
Parents: 98ea82a
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Wed Dec 9 11:57:20 2015 -0800
Committer: Guozhang Wang <wangguoz@gmail.com>
Committed: Wed Dec 9 11:57:20 2015 -0800

----------------------------------------------------------------------
 .../common/requests/ControlledShutdownResponse.java    |  1 +
 .../kafka/common/requests/RequestResponseTest.java     | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/7bb7e415/clients/src/main/java/org/apache/kafka/common/requests/ControlledShutdownResponse.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/requests/ControlledShutdownResponse.java
b/clients/src/main/java/org/apache/kafka/common/requests/ControlledShutdownResponse.java
index 15d600d..1f4af7c 100644
--- a/clients/src/main/java/org/apache/kafka/common/requests/ControlledShutdownResponse.java
+++ b/clients/src/main/java/org/apache/kafka/common/requests/ControlledShutdownResponse.java
@@ -52,6 +52,7 @@ public class ControlledShutdownResponse extends AbstractRequestResponse
{
             Struct topicPartitionStruct = struct.instance(PARTITIONS_REMAINING_KEY_NAME);
             topicPartitionStruct.set(TOPIC_KEY_NAME, topicPartition.topic());
             topicPartitionStruct.set(PARTITION_KEY_NAME, topicPartition.partition());
+            partitionsRemainingList.add(topicPartitionStruct);
         }
         struct.set(PARTITIONS_REMAINING_KEY_NAME, partitionsRemainingList.toArray());
 

http://git-wip-us.apache.org/repos/asf/kafka/blob/7bb7e415/clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java
b/clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java
index ab18817..69431a5 100644
--- a/clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java
@@ -148,6 +148,17 @@ public class RequestResponseTest {
         assertEquals("Response data does not match", responseData, v1Response.responseData());
     }
 
+    @Test
+    public void testControlledShutdownResponse() {
+        ControlledShutdownResponse response = createControlledShutdownResponse();
+        ByteBuffer buffer = ByteBuffer.allocate(response.sizeOf());
+        response.writeTo(buffer);
+        buffer.rewind();
+        ControlledShutdownResponse deserialized = ControlledShutdownResponse.parse(buffer);
+        assertEquals(response.errorCode(), deserialized.errorCode());
+        assertEquals(response.partitionsRemaining(), deserialized.partitionsRemaining());
+    }
+
 
     private AbstractRequestResponse createRequestHeader() {
         return new RequestHeader((short) 10, (short) 1, "", 10);
@@ -311,7 +322,7 @@ public class RequestResponseTest {
         return new ControlledShutdownRequest(10);
     }
 
-    private AbstractRequestResponse createControlledShutdownResponse() {
+    private ControlledShutdownResponse createControlledShutdownResponse() {
         HashSet<TopicPartition> topicPartitions = new HashSet<>(Arrays.asList(
                 new TopicPartition("test2", 5),
                 new TopicPartition("test1", 10)


Mime
View raw message