Browse Source

For empty arrays send null to query all topics

unknown 5 years ago
parent
commit
5d1949b1c1
1 changed files with 10 additions and 1 deletions
  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++ {