Skip to content

Commit 8f4ff3e

Browse files
NH-3966 - fix.
1 parent fb7dd79 commit 8f4ff3e

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/NHibernate/AdoNet/AbstractBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ protected void CheckReaders()
265265
}
266266
}
267267

268-
public void CloseCommands()
268+
public virtual void CloseCommands()
269269
{
270270
_releasing = true;
271271
try

src/NHibernate/AdoNet/MySqlClientBatchingBatcher.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Data.Common;
23
using System.Text;
34
using NHibernate.AdoNet.Util;
@@ -97,5 +98,21 @@ private MySqlClientSqlCommandSet CreateConfiguredBatch()
9798
{
9899
return new MySqlClientSqlCommandSet(batchSize);
99100
}
101+
102+
public override void CloseCommands()
103+
{
104+
base.CloseCommands();
105+
106+
try
107+
{
108+
currentBatch.Dispose();
109+
}
110+
catch (Exception e)
111+
{
112+
// Prevent exceptions when closing the batch from hiding any original exception
113+
// (We do not know here if this batch closing occurs after a failure or not.)
114+
Log.Warn("Exception closing batcher", e);
115+
}
116+
}
100117
}
101118
}

src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,21 @@ private SqlClientSqlCommandSet CreateConfiguredBatch()
117117

118118
return result;
119119
}
120+
121+
public override void CloseCommands()
122+
{
123+
base.CloseCommands();
124+
125+
try
126+
{
127+
_currentBatch.Dispose();
128+
}
129+
catch (Exception e)
130+
{
131+
// Prevent exceptions when closing the batch from hiding any original exception
132+
// (We do not know here if this batch closing occurs after a failure or not.)
133+
Log.Warn("Exception closing batcher", e);
134+
}
135+
}
120136
}
121137
}

0 commit comments

Comments
 (0)