[#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,9 +76,18 @@ 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) {
if exec.prm.forwarder != nil {
return exec.prm.forwarder(c.client) 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) {
r, err := (*engine.StorageEngine)(e).Select(new(engine.SelectPrm). r, err := (*engine.StorageEngine)(e).Select(new(engine.SelectPrm).
WithFilters(exec.searchFilters()). WithFilters(exec.searchFilters()).