[#1662] object: Fix CloseAndRecv for patch streamer
All checks were successful
DCO action / DCO (pull_request) Successful in 37s
Tests and linters / Run gofumpt (pull_request) Successful in 35s
Vulncheck / Vulncheck (pull_request) Successful in 1m5s
Build / Build Components (pull_request) Successful in 1m41s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m56s
Tests and linters / Staticcheck (pull_request) Successful in 2m20s
Tests and linters / Tests (pull_request) Successful in 2m23s
Tests and linters / gopls check (pull_request) Successful in 2m52s
Tests and linters / Lint (pull_request) Successful in 2m58s
Tests and linters / Tests with -race (pull_request) Successful in 3m34s

* 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 1801e01155
commit 9eabb0a03d

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