Skip to content

Commit

Permalink
Merge pull request #298 from ExpediaGroup/fix-null-pointers
Browse files Browse the repository at this point in the history
fix: null pointer when connection not available
  • Loading branch information
sumitanvekar authored Jun 13, 2023
2 parents 9bd1756 + 23ebdc4 commit 6513f72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/pkg/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package grpc

import (
"bytes"
"errors"
"fmt"
"google.golang.org/grpc/credentials/insecure"
"log"
Expand Down Expand Up @@ -122,6 +123,11 @@ func (c *Client) SendRequest(serviceMethod string, message string, headers []str
interpolatedHeaders[i] = placeholders.InterpolatePlaceholders(header)
}

if c.conn == nil {
log.Printf("No connection available. Skip making request.")
return response.Response{Duration: time.Duration(0), Err: errors.New("no connection available"), Type: respType}
}

err = grpcurl.InvokeRPC(context.Background(), c.descriptorSource, c.conn, serviceMethod, interpolatedHeaders, loggingEventHandler, requestParser.Next)
endTime := time.Now()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/warmup/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (t Target) WaitForReadinessProbe(maxReadinessWaitDurationInSeconds int, hea
connErr := t.readinessGrpcClient.Connect(nil)
if connErr != nil {
log.Printf("gRPC readiness client connect error: %v", connErr)
continue
}
err1 := t.readinessGrpcClient.SendRequest(request.ServiceMethod, "", headers, false)
if err1.Err != nil {
Expand Down

0 comments on commit 6513f72

Please sign in to comment.