Skip to content

Commit 4138171

Browse files
albertodallhazzik
authored andcommitted
Short-Circuit SessionFactoryImpl.Close() when already closed (#2223)
1 parent a41010f commit 4138171

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/NHibernate/Async/Impl/SessionFactoryImpl.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ public sealed partial class SessionFactoryImpl : ISessionFactoryImplementor, IOb
6363
public async Task CloseAsync(CancellationToken cancellationToken = default(CancellationToken))
6464
{
6565
cancellationToken.ThrowIfCancellationRequested();
66+
if (isClosed)
67+
{
68+
if (log.IsDebugEnabled())
69+
{
70+
log.Debug("Already closed");
71+
}
72+
73+
return;
74+
}
75+
6676
log.Info("Closing");
6777

6878
isClosed = true;

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,16 @@ public void Dispose()
857857
/// </summary>
858858
public void Close()
859859
{
860+
if (isClosed)
861+
{
862+
if (log.IsDebugEnabled())
863+
{
864+
log.Debug("Already closed");
865+
}
866+
867+
return;
868+
}
869+
860870
log.Info("Closing");
861871

862872
isClosed = true;

0 commit comments

Comments
 (0)