mirror of
https://github.com/distribution/distribution.git
synced 2026-05-01 12:55:30 +00:00
fix: nil-check scheduler in proxyingRegistry.Close() (#4805)
This commit is contained in:
@@ -229,6 +229,9 @@ type Closer interface {
|
||||
}
|
||||
|
||||
func (pr *proxyingRegistry) Close() error {
|
||||
if pr.scheduler == nil {
|
||||
return nil
|
||||
}
|
||||
return pr.scheduler.Stop()
|
||||
}
|
||||
|
||||
|
||||
17
registry/proxy/proxyregistry_test.go
Normal file
17
registry/proxy/proxyregistry_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProxyingRegistryCloseWithoutScheduler(t *testing.T) {
|
||||
pr := &proxyingRegistry{
|
||||
scheduler: nil,
|
||||
}
|
||||
|
||||
// verify that `Close()` does not panic when the scheduler is nil
|
||||
err := pr.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Close() returned unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user