Skip to content
This repository was archived by the owner on Apr 20, 2019. It is now read-only.

Commit 4ea3f9c

Browse files
committed
CSHARP-2339: Only call AbortTransaction from Dispose when appropriate.
1 parent 41956ed commit 4ea3f9c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/MongoDB.Driver.Core/Core/Bindings/CoreSession.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,19 @@ public void Dispose()
322322
{
323323
if (_currentTransaction != null)
324324
{
325-
try
326-
{
327-
AbortTransaction(CancellationToken.None);
328-
}
329-
catch
325+
switch (_currentTransaction.State)
330326
{
331-
// ignore exceptions
327+
case CoreTransactionState.Starting:
328+
case CoreTransactionState.InProgress:
329+
try
330+
{
331+
AbortTransaction(CancellationToken.None);
332+
}
333+
catch
334+
{
335+
// ignore exceptions
336+
}
337+
break;
332338
}
333339
}
334340

0 commit comments

Comments
 (0)