File tree Expand file tree Collapse file tree 2 files changed +0
-39
lines changed
Expand file tree Collapse file tree 2 files changed +0
-39
lines changed Original file line number Diff line number Diff line change 1515package etcdserver
1616
1717import (
18- "fmt"
1918 "time"
2019
2120 "go.etcd.io/etcd/client/pkg/v3/types"
@@ -96,21 +95,3 @@ func (nc *notifier) notify(err error) {
9695 nc .err = err
9796 close (nc .c )
9897}
99-
100- // panicAlternativeStringer wraps a fmt.Stringer, and if calling String() panics, calls the alternative instead.
101- // This is needed to ensure logging slow v2 requests does not panic, which occurs when running integration tests
102- // with the embedded server with github.com/golang/protobuf v1.4.0+. See https://github.com/etcd-io/etcd/issues/12197.
103- type panicAlternativeStringer struct {
104- stringer fmt.Stringer
105- alternative func () string
106- }
107-
108- func (n panicAlternativeStringer ) String () (s string ) {
109- defer func () {
110- if err := recover (); err != nil {
111- s = n .alternative ()
112- }
113- }()
114- s = n .stringer .String ()
115- return s
116- }
Original file line number Diff line number Diff line change @@ -90,23 +90,3 @@ func (s *nopTransporterWithActiveTime) Stop() {}
9090func (s * nopTransporterWithActiveTime ) Pause () {}
9191func (s * nopTransporterWithActiveTime ) Resume () {}
9292func (s * nopTransporterWithActiveTime ) reset (am map [types.ID ]time.Time ) { s .activeMap = am }
93-
94- func TestPanicAlternativeStringer (t * testing.T ) {
95- p := panicAlternativeStringer {alternative : func () string { return "alternative" }}
96-
97- p .stringer = testStringerFunc (func () string { panic ("here" ) })
98- if s := p .String (); s != "alternative" {
99- t .Fatalf ("expected 'alternative', got %q" , s )
100- }
101-
102- p .stringer = testStringerFunc (func () string { return "test" })
103- if s := p .String (); s != "test" {
104- t .Fatalf ("expected 'test', got %q" , s )
105- }
106- }
107-
108- type testStringerFunc func () string
109-
110- func (s testStringerFunc ) String () string {
111- return s ()
112- }
You can’t perform that action at this time.
0 commit comments