Skip to content

Commit 2b75302

Browse files
benjirewisBenjamin Rewis
authored andcommitted
GODRIVER-1890 Add nil Client checks (#590)
1 parent d07cbc8 commit 2b75302

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

x/mongo/driver/operation.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ func (op Operation) Execute(ctx context.Context, scratch []byte) error {
384384
connDesc := conn.Description()
385385
retryableErr := tt.Retryable(connDesc.WireVersion)
386386
preRetryWriteLabelVersion := connDesc.WireVersion != nil && connDesc.WireVersion.Max < 9
387-
inTransaction := !(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
387+
inTransaction := op.Client != nil &&
388+
!(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
388389
// If retry is enabled and the operation isn't in a transaction, add a RetryableWriteError label for
389390
// retryable errors from pre-4.4 servers
390391
if retryableErr && preRetryWriteLabelVersion && retryEnabled && !inTransaction {
@@ -465,7 +466,8 @@ func (op Operation) Execute(ctx context.Context, scratch []byte) error {
465466
if op.Type == Write {
466467
retryableErr = tt.RetryableWrite(connDesc.WireVersion)
467468
preRetryWriteLabelVersion := connDesc.WireVersion != nil && connDesc.WireVersion.Max < 9
468-
inTransaction := !(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
469+
inTransaction := op.Client != nil &&
470+
!(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
469471
// If retryWrites is enabled and the operation isn't in a transaction, add a RetryableWriteError label
470472
// for network errors and retryable errors from pre-4.4 servers
471473
if retryEnabled && !inTransaction &&

0 commit comments

Comments
 (0)