[#xx] object: Fix CloseAndRecv for patch streamer
Some checks failed
DCO action / DCO (pull_request) Failing after 27s
Vulncheck / Vulncheck (pull_request) Successful in 1m0s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m22s
Build / Build Components (pull_request) Successful in 1m29s
Tests and linters / Lint (pull_request) Successful in 3m15s
Tests and linters / Staticcheck (pull_request) Successful in 3m10s
Tests and linters / Run gofumpt (pull_request) Successful in 2m58s
Tests and linters / Tests (pull_request) Successful in 3m2s
Tests and linters / Tests with -race (pull_request) Successful in 4m14s
Tests and linters / gopls check (pull_request) Successful in 4m22s

* 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 4951e77bfd

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