Skip to content

Commit 3f63b43

Browse files
committed
Have Dispose(true) call Close() instead of Close() call Dispose(true).
More close to the expected pattern
1 parent 9c65872 commit 3f63b43

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

DuckDB.NET.Data/DuckDBConnection.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ public override void Close()
9595
throw new InvalidOperationException("Connection is already closed.");
9696
}
9797

98-
Dispose(true);
98+
if (connectionReference is not null) //Should always be the case
99+
{
100+
connectionManager.ReturnConnectionReference(connectionReference);
101+
}
102+
103+
connectionState = ConnectionState.Closed;
104+
OnStateChange(FromOpenToClosedEventArgs);
99105
}
100106

101107
public override void Open()
@@ -182,15 +188,10 @@ protected override void Dispose(bool disposing)
182188
{
183189
if (disposing)
184190
{
191+
// this check is to ensure exact same behavior as previous version
192+
// where Close() was calling Dispose(true) instead of the other way around.
185193
if (connectionState == ConnectionState.Open)
186-
{
187-
if (connectionReference is not null) //Should always be the case
188-
{
189-
connectionManager.ReturnConnectionReference(connectionReference);
190-
}
191-
connectionState = ConnectionState.Closed;
192-
OnStateChange(FromOpenToClosedEventArgs);
193-
}
194+
Close();
194195
}
195196

196197
base.Dispose(disposing);

0 commit comments

Comments
 (0)