From b587b23e79eab850536dc75401d7ed6a352a167c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 20 May 2021 11:05:18 +0300 Subject: [PATCH] [#543] object/search: Fix potential NPE on request forwarder Request forwarding callback should be called only if set since it is an optional parameter. Call `forwarder` function only if it is non-nil. Signed-off-by: Leonard Lyubich --- pkg/services/object/search/util.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/services/object/search/util.go b/pkg/services/object/search/util.go index 7a2073e3b..5a8295645 100644 --- a/pkg/services/object/search/util.go +++ b/pkg/services/object/search/util.go @@ -76,7 +76,16 @@ func (c *clientConstructorWrapper) get(addr string) (searchClient, error) { } func (c *clientWrapper) searchObjects(exec *execCtx) ([]*objectSDK.ID, error) { - return exec.prm.forwarder(c.client) + if exec.prm.forwarder != nil { + return exec.prm.forwarder(c.client) + } + + return c.client.SearchObject(exec.context(), + &exec.prm.SearchObjectParams, + exec.prm.common.RemoteCallOptions( + util.WithNetmapEpoch(exec.curProcEpoch), + util.WithKey(exec.prm.common.PrivateKey()), + )...) } func (e *storageEngineWrapper) search(exec *execCtx) ([]*objectSDK.ID, error) {