Skip to content

Commit d1a8832

Browse files
committed
Fix a wrong usage of recover in apiserver.
1 parent c8ceeed commit d1a8832

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

staging/src/k8s.io/apiserver/pkg/util/wsstream/stream.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type Reader struct {
6363
protocols map[string]ReaderProtocolConfig
6464
selectedProtocol string
6565

66-
handleCrash func() // overridable for testing
66+
handleCrash func(additionalHandlers ...func(interface{})) // overridable for testing
6767
}
6868

6969
// 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
7878
err: make(chan error),
7979
ping: ping,
8080
protocols: protocols,
81-
handleCrash: func() { runtime.HandleCrash() },
81+
handleCrash: runtime.HandleCrash,
8282
}
8383
}
8484

staging/src/k8s.io/apiserver/pkg/util/wsstream/stream_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestStreamSurvivesPanic(t *testing.T) {
169169
r := NewReader(errs, false, NewDefaultReaderProtocols())
170170

171171
// do not call runtime.HandleCrash() in handler. Otherwise, the tests are interrupted.
172-
r.handleCrash = func() { recover() }
172+
r.handleCrash = func(additionalHandlers ...func(interface{})) { recover() }
173173

174174
data, err := readWebSocket(r, t, nil)
175175
if !reflect.DeepEqual(data, []byte(input)) {

0 commit comments

Comments
 (0)