diff --git a/sdk/azcore/runtime/pager.go b/sdk/azcore/runtime/pager.go index 53871eb02a5b..1ad1fe4bfcca 100644 --- a/sdk/azcore/runtime/pager.go +++ b/sdk/azcore/runtime/pager.go @@ -39,13 +39,14 @@ type PageProcessor[T any] struct { type Pager[T any] struct { current T handler PageProcessor[T] - lroSecond bool + firstPage bool } // NewPager creates an instance of Pager using the specified PageProcessor. func NewPager[T any](pageHandler PageProcessor[T]) *Pager[T] { return &Pager[T]{ - handler: pageHandler, + handler: pageHandler, + firstPage: true, } } @@ -61,9 +62,9 @@ func (p *Pager[T]) More() bool { func (p *Pager[T]) NextPage(ctx context.Context) (T, error) { var req *policy.Request var err error - if !reflect.ValueOf(p.current).IsZero() && !p.lroSecond { + if !reflect.ValueOf(p.current).IsZero() && p.firstPage { // we get here if it's an LRO-pager, we already have the first page - p.lroSecond = true + p.firstPage = false return p.current, nil } else if !reflect.ValueOf(p.current).IsZero() { if !p.handler.More(p.current) { @@ -71,8 +72,8 @@ func (p *Pager[T]) NextPage(ctx context.Context) (T, error) { } req, err = p.handler.Advancer(ctx, p.current) } else { - // non-LRO case, so skip the LRO branch above - p.lroSecond = true + // non-LRO case + p.firstPage = false req, err = p.handler.Requester(ctx) } if err != nil {