Skip to content

Commit

Permalink
fix: null pointer when connection not available
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitanvekar committed Jun 12, 2023
1 parent 9bd1756 commit 21acd29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/pkg/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,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: err, 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 21acd29

Please sign in to comment.