Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a wrong usage of recover in apiserver #91566

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions staging/src/k8s.io/apiserver/pkg/util/wsstream/stream.go
Expand Up @@ -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
Expand All @@ -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,
}
}

Expand Down
Expand Up @@ -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)) {
Expand Down