Merge pull request #91566 from RainbowMango/pr_fix_invalid_recover_in_apiserver
Fix a wrong usage of recover in apiserver Kubernetes-commit: ae1103726f9aea1f9bbad1b215edfa47e0747dce
This commit is contained in:
commit
42642e7cb5
|
|
@ -63,7 +63,7 @@ type Reader struct {
|
||||||
protocols map[string]ReaderProtocolConfig
|
protocols map[string]ReaderProtocolConfig
|
||||||
selectedProtocol string
|
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
|
// 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),
|
err: make(chan error),
|
||||||
ping: ping,
|
ping: ping,
|
||||||
protocols: protocols,
|
protocols: protocols,
|
||||||
handleCrash: func() { runtime.HandleCrash() },
|
handleCrash: runtime.HandleCrash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ func TestStreamSurvivesPanic(t *testing.T) {
|
||||||
r := NewReader(errs, false, NewDefaultReaderProtocols())
|
r := NewReader(errs, false, NewDefaultReaderProtocols())
|
||||||
|
|
||||||
// do not call runtime.HandleCrash() in handler. Otherwise, the tests are interrupted.
|
// 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)
|
data, err := readWebSocket(r, t, nil)
|
||||||
if !reflect.DeepEqual(data, []byte(input)) {
|
if !reflect.DeepEqual(data, []byte(input)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue