[#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>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2021-05-20 11:05:18 +03:00 committed by Alex Vanin
parent b2002ffc6d
commit b587b23e79
1 changed files with 10 additions and 1 deletions

View File

@ -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) {