diff --git a/src/NHibernate/Impl/SessionImpl.cs b/src/NHibernate/Impl/SessionImpl.cs
index 5104aea9f27..9a0a119b1fa 100644
--- a/src/NHibernate/Impl/SessionImpl.cs
+++ b/src/NHibernate/Impl/SessionImpl.cs
@@ -1483,14 +1483,6 @@ public void Reconnect(DbConnection conn)
private string fetchProfile;
private IDisposable _context;
- ///
- /// Finalizer that ensures the object is correctly disposed of.
- ///
- ~SessionImpl()
- {
- Dispose(false);
- }
-
///
/// Perform a soft (distributed transaction aware) close of the session
///
@@ -1517,15 +1509,12 @@ public void Dispose()
_context?.Dispose();
}
+ //TODO: Get rid of isDisposing parameter. Finalizer is removed as not needed, so isDisposing is always true
///
/// Takes care of freeing the managed and unmanaged resources that
/// this class is responsible for.
///
/// Indicates if this Session is being Disposed of or Finalized.
- ///
- /// If this Session is being Finalized (isDisposing==false) then make sure not
- /// to call any methods that could potentially bring this Session back to life.
- ///
private void Dispose(bool isDisposing)
{
using (BeginContext())
@@ -1546,8 +1535,6 @@ private void Dispose(bool isDisposing)
{
Close();
}
- // nothing for Finalizer to do - so tell the GC to ignore it
- GC.SuppressFinalize(this);
}
// free unmanaged resources here
diff --git a/src/NHibernate/Impl/StatelessSessionImpl.cs b/src/NHibernate/Impl/StatelessSessionImpl.cs
index b42b746b593..61148f603a2 100644
--- a/src/NHibernate/Impl/StatelessSessionImpl.cs
+++ b/src/NHibernate/Impl/StatelessSessionImpl.cs
@@ -759,14 +759,6 @@ public IQueryOver QueryOver(Expression> alias) where T : class
private bool _isAlreadyDisposed;
private IDisposable _context;
- ///
- /// Finalizer that ensures the object is correctly disposed of.
- ///
- ~StatelessSessionImpl()
- {
- Dispose(false);
- }
-
///
///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
@@ -793,6 +785,7 @@ public void Dispose()
}
}
+ //TODO: Get rid of isDisposing parameter. Finalizer is removed as not needed, so isDisposing is always true
protected void Dispose(bool isDisposing)
{
using (BeginContext())
@@ -811,9 +804,6 @@ protected void Dispose(bool isDisposing)
{
Close();
}
-
- // nothing for Finalizer to do - so tell the GC to ignore it
- GC.SuppressFinalize(this);
}
// free unmanaged resources here