浏览代码

Fix FindCoordinatorResponse.encode to allow nil Coordinator

Maxim Vladimirskiy 7 年之前
父节点
当前提交
20e9b58ec1
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      find_coordinator_response.go

+ 13 - 1
find_coordinator_response.go

@@ -60,10 +60,22 @@ func (f *FindCoordinatorResponse) encode(pe packetEncoder) error {
 		}
 		}
 	}
 	}
 
 
+	if f.Coordinator == nil {
+		pe.putInt32(0)
+		if err := pe.putString(""); err != nil {
+			return nil
+		}
+		pe.putInt32(0)
+		if f.Version >= 1 {
+			if err := pe.putNullableString(nil); err != nil {
+				return nil
+			}
+		}
+		return nil
+	}
 	if err := f.Coordinator.encode(pe, 0); err != nil {
 	if err := f.Coordinator.encode(pe, 0); err != nil {
 		return err
 		return err
 	}
 	}
-
 	return nil
 	return nil
 }
 }