[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-20 11:05:18 +03:00 committed by Alex Vanin
parent b2002ffc6d
commit b587b23e79

View file

@ -76,7 +76,16 @@ func (c *clientConstructorWrapper) get(addr string) (searchClient, error) {
} }
func (c *clientWrapper) searchObjects(exec *execCtx) ([]*objectSDK.ID, 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) { func (e *storageEngineWrapper) search(exec *execCtx) ([]*objectSDK.ID, error) {