[#532] object/hash: Fix NPE during request forwarding
In current implementation `Object.GetRangeHash` RPC handler forwards range requests for payload data. Missing request forwarder of the original request caused NPE during execution. Do not call request forwarder if payload range hash is requested. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5e9513e008
commit
72e2bc8fb6
3 changed files with 18 additions and 4 deletions
|
@ -38,7 +38,7 @@ type execCtx struct {
|
|||
|
||||
curOff uint64
|
||||
|
||||
head bool
|
||||
head, hash bool
|
||||
|
||||
curProcEpoch uint64
|
||||
|
||||
|
@ -71,6 +71,12 @@ func withPayloadRange(r *objectSDK.Range) execOption {
|
|||
}
|
||||
}
|
||||
|
||||
func hashOnly() execOption {
|
||||
return func(c *execCtx) {
|
||||
c.hash = true
|
||||
}
|
||||
}
|
||||
|
||||
func (exec *execCtx) setLogger(l *logger.Logger) {
|
||||
req := "GET"
|
||||
if exec.headOnly() {
|
||||
|
@ -146,6 +152,10 @@ func (exec *execCtx) headOnly() bool {
|
|||
return exec.head
|
||||
}
|
||||
|
||||
func (exec *execCtx) hashOnly() bool {
|
||||
return exec.hash
|
||||
}
|
||||
|
||||
func (exec *execCtx) netmapEpoch() uint64 {
|
||||
return exec.prm.common.NetmapEpoch()
|
||||
}
|
||||
|
|
|
@ -15,7 +15,11 @@ func (s *Service) Get(ctx context.Context, prm Prm) error {
|
|||
|
||||
// GetRange serves a request to get an object by address, and returns Streamer instance.
|
||||
func (s *Service) GetRange(ctx context.Context, prm RangePrm) error {
|
||||
return s.get(ctx, prm.commonPrm, withPayloadRange(prm.rng)).err
|
||||
return s.getRange(ctx, prm)
|
||||
}
|
||||
|
||||
func (s *Service) getRange(ctx context.Context, prm RangePrm, opts ...execOption) error {
|
||||
return s.get(ctx, prm.commonPrm, append(opts, withPayloadRange(prm.rng))...).err
|
||||
}
|
||||
|
||||
func (s *Service) GetRangeHash(ctx context.Context, prm RangeHashPrm) (*RangeHashRes, error) {
|
||||
|
@ -37,7 +41,7 @@ func (s *Service) GetRangeHash(ctx context.Context, prm RangeHashPrm) (*RangeHas
|
|||
hash: util.NewSaltingWriter(h, prm.salt),
|
||||
})
|
||||
|
||||
if err := s.GetRange(ctx, rngPrm); err != nil {
|
||||
if err := s.getRange(ctx, rngPrm, hashOnly()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ func (c *clientCacheWrapper) get(addr string) (getClient, error) {
|
|||
}
|
||||
|
||||
func (c *clientWrapper) getObject(exec *execCtx) (*objectSDK.Object, error) {
|
||||
if !exec.assembling {
|
||||
if !exec.assembling && !exec.hashOnly() {
|
||||
return exec.prm.forwarder(c.client)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue