Skip to content

Commit

Permalink
log error
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Jul 29, 2022
1 parent b4efd2d commit 23432ac
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions dialoptions.go
Expand Up @@ -392,6 +392,7 @@ func WithDialer(f func(string, time.Duration) (net.Conn, error)) DialOption {
func WithStatsHandler(h stats.Handler) DialOption {
return newFuncDialOption(func(o *dialOptions) {
if h == nil {
logger.Error("ignoring nil parameter in grpc.WithStatsHandler ClientOption")
// Do not allow a nil stats handler, which would otherwise cause
// panics.
return
Expand Down
1 change: 1 addition & 0 deletions server.go
Expand Up @@ -443,6 +443,7 @@ func InTapHandle(h tap.ServerInHandle) ServerOption {
func StatsHandler(h stats.Handler) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
if h == nil {
logger.Error("ignoring nil parameter in grpc.StatsHandler ServerOption")
// Do not allow a nil stats handler, which would otherwise cause
// panics.
return
Expand Down
1 change: 1 addition & 0 deletions test/end2end_test.go
Expand Up @@ -8045,6 +8045,7 @@ func (s) TestServerClosesConn(t *testing.T) {
// TestNilStatsHandler ensures we do not panic as a result of a nil stats
// handler.
func (s) TestNilStatsHandler(t *testing.T) {
grpctest.TLogger.ExpectErrorN("ignoring nil parameter", 2)
ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil
Expand Down

0 comments on commit 23432ac

Please sign in to comment.