[#1662] object: Fix CloseAndRecv for patch streamer

* A client may open stream to server, not send anything and close
  the open stream immediatly. This shouldn't cause a panic;
* Return the error if `s.patcher` is uninitialized. Uninitialized
  patcher cannot be closed, this causes a panic.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2025-03-05 17:09:02 +03:00
parent bf8914fedc
commit 4c8f9580a1

View file

@ -214,6 +214,9 @@ func (s *Streamer) Send(ctx context.Context, req *objectV2.PatchRequest) error {
}
func (s *Streamer) CloseAndRecv(ctx context.Context) (*objectV2.PatchResponse, error) {
if s.patcher == nil {
return nil, errors.New("uninitialized patch streamer")
}
patcherResp, err := s.patcher.Close(ctx)
if err != nil {
return nil, err