瀏覽代碼

For empty arrays send null to query all topics

unknown 5 年之前
父節點
當前提交
5d1949b1c1
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      describe_log_dirs_request.go

+ 10 - 1
describe_log_dirs_request.go

@@ -17,7 +17,13 @@ type DescribeLogDirsRequestTopic struct {
 }
 
 func (r *DescribeLogDirsRequest) encode(pe packetEncoder) error {
-	if err := pe.putArrayLength(len(r.DescribeTopics)); err != nil {
+	length := len(r.DescribeTopics)
+	if length == 0 {
+		// In order to query all topics we must send null
+		length = -1
+	}
+
+	if err := pe.putArrayLength(length); err != nil {
 		return err
 	}
 
@@ -39,6 +45,9 @@ func (r *DescribeLogDirsRequest) decode(pd packetDecoder, version int16) error {
 	if err != nil {
 		return err
 	}
+	if n == -1 {
+		n = 0
+	}
 
 	topics := make([]DescribeLogDirsRequestTopic, n)
 	for i := 0; i < n; i++ {