@@ -458,7 +458,7 @@ def with_transaction(options = nil)
458458 overload_error_count = 0
459459 overload_encountered = false
460460
461- loop do
461+ loop do # rubocop:disable Metrics/BlockLength
462462 if transaction_attempt > 0
463463 if overload_encountered
464464 delay = @client . retry_policy . backoff_delay ( overload_error_count )
@@ -539,11 +539,10 @@ def with_transaction(options = nil)
539539 if deadline_expired? ( deadline ) ||
540540 ( e . is_a? ( Error ::OperationFailure ::Family ) && e . max_time_ms_expired? )
541541 transaction_in_progress = false
542- if @with_transaction_timeout_ms && deadline_expired? ( deadline )
543- make_timeout_error_from ( e , 'CSOT timeout expired during withTransaction commit' )
544- else
545- raise
546- end
542+
543+ raise unless @with_transaction_timeout_ms && deadline_expired? ( deadline )
544+
545+ make_timeout_error_from ( e , 'CSOT timeout expired during withTransaction commit' )
547546 end
548547
549548 if e . label? ( 'SystemOverloadedError' )
@@ -1401,12 +1400,9 @@ def backoff_would_exceed_deadline?(deadline, backoff_seconds)
14011400 # In CSOT mode raises TimeoutError with last_error's message included as a substring.
14021401 # In non-CSOT mode re-raises last_error directly.
14031402 def make_timeout_error_from ( last_error , timeout_message )
1404- if @with_transaction_timeout_ms
1405- raise Mongo ::Error ::TimeoutError , "#{ timeout_message } : #{ last_error } "
1406- else
1407- raise last_error
1408- end
1409- end
1403+ raise Mongo ::Error ::TimeoutError , "#{ timeout_message } : #{ last_error } " if @with_transaction_timeout_ms
14101404
1405+ raise last_error
1406+ end
14111407 end
14121408end
0 commit comments