Skip to content

Commit 09c90b1

Browse files
committed
Prevent exceptions leaving Dispose. Fixes #923
1 parent a9990d6 commit 09c90b1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/MySqlConnector/MySqlTransaction.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Data;
33
using System.Data.Common;
4+
using System.IO;
5+
using System.Net.Sockets;
46
using System.Threading;
57
using System.Threading.Tasks;
68
using MySqlConnector.Protocol.Serialization;
@@ -224,8 +226,17 @@ private async ValueTask DoDisposeAsync(IOBehavior ioBehavior, CancellationToken
224226
{
225227
if (Connection.State == ConnectionState.Open && Connection.Session.IsConnected)
226228
{
227-
using (var cmd = new MySqlCommand("rollback", Connection, this))
229+
try
230+
{
231+
using var cmd = new MySqlCommand("rollback", Connection, this);
228232
await cmd.ExecuteNonQueryAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
233+
}
234+
catch (IOException)
235+
{
236+
}
237+
catch (SocketException)
238+
{
239+
}
229240
}
230241
Connection.CurrentTransaction = null;
231242
}

0 commit comments

Comments
 (0)