Fix a wrong usage of recover in apiserver.

Kubernetes-commit: d1a883293930336b5c561448900e40d9c4fe4676
This commit is contained in:
RainbowMango 2020-05-29 17:03:43 +08:00 committed by Kubernetes Publisher
parent 88acf3194f
commit efc2982011
2 changed files with 3 additions and 3 deletions

View File

@ -63,7 +63,7 @@ type Reader struct {
protocols map[string]ReaderProtocolConfig
selectedProtocol string
handleCrash func() // overridable for testing
handleCrash func(additionalHandlers ...func(interface{})) // overridable for testing
}
// NewReader creates a WebSocket pipe that will copy the contents of r to a provided
@ -78,7 +78,7 @@ func NewReader(r io.Reader, ping bool, protocols map[string]ReaderProtocolConfig
err: make(chan error),
ping: ping,
protocols: protocols,
handleCrash: func() { runtime.HandleCrash() },
handleCrash: runtime.HandleCrash,
}
}

View File

@ -169,7 +169,7 @@ func TestStreamSurvivesPanic(t *testing.T) {
r := NewReader(errs, false, NewDefaultReaderProtocols())
// do not call runtime.HandleCrash() in handler. Otherwise, the tests are interrupted.
r.handleCrash = func() { recover() }
r.handleCrash = func(additionalHandlers ...func(interface{})) { recover() }
data, err := readWebSocket(r, t, nil)
if !reflect.DeepEqual(data, []byte(input)) {