Skip to content

Commit 338a827

Browse files
Fix a null reference case in session context
1 parent 4edbbed commit 338a827

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ public void WillGetSessionIdFromSessionLogsConcurrent()
192192
}
193193
}
194194

195+
[Test]
196+
public void WillCleanlyFailOnDoubleProcessDispose()
197+
{
198+
using (var s = OpenSession())
199+
{
200+
var p = ((AbstractSessionImpl) s).BeginProcess();
201+
p.Dispose();
202+
Assert.That(() => p.Dispose(), Throws.TypeOf<ObjectDisposedException>());
203+
}
204+
}
205+
195206
// IFixingRequired interface ensures the value is evaluated at log time rather than at log buffer flush time.
196207
public class SessionIdCapturer : IFixingRequired
197208
{

src/NHibernate/Impl/AbstractSessionImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public ProcessHelper(AbstractSessionImpl session)
329329

330330
public void Dispose()
331331
{
332-
_context.Dispose();
332+
_context?.Dispose();
333333
_context = null;
334334
if (_session == null)
335335
throw new ObjectDisposedException("The session process helper has been disposed already");

0 commit comments

Comments
 (0)