Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX | Throwing exception from Dispose should not happen #920

Merged
merged 3 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,18 @@ private void CleanPartialReadReliable()
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/Dispose/*' />
protected override void Dispose(bool disposing)
{
if (disposing)
try
{
Close();
if (disposing)
{
Close();
}
base.Dispose(disposing);
}
catch(SqlException ex)
{
SqlClientEventSource.Log.TryTraceEvent("SqlDataReader.Dispose | ERR | Error Message: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
}
base.Dispose(disposing);
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/Close/*' />
Expand Down Expand Up @@ -2966,7 +2973,7 @@ override public int GetValues(object[] values)
if ((sequentialAccess) && (i < maximumColumn))
{
_data[fieldIndex].Clear();
if (fieldIndex > i && fieldIndex>0)
if (fieldIndex > i && fieldIndex > 0)
{
// if we jumped an index forward because of a hidden column see if the buffer before the
// current one was populated by the seek forward and clear it if it was
Expand Down Expand Up @@ -4515,7 +4522,7 @@ out bytesRead
if (!isContinuation)
{
// This is the first async operation which is happening - setup the _currentTask and timeout
Debug.Assert(context._source==null, "context._source should not be non-null when trying to change to async");
Debug.Assert(context._source == null, "context._source should not be non-null when trying to change to async");
source = new TaskCompletionSource<int>();
Task original = Interlocked.CompareExchange(ref _currentTask, source.Task, null);
if (original != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,23 @@ private void CleanPartialReadReliable()
}
}

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/Dispose/*' />
protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
Close();
}
base.Dispose(disposing);
}
catch (SqlException ex)
{
SqlClientEventSource.Log.TryTraceEvent("SqlDataReader.Dispose | ERR | Error Message: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace);
}
}

/// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/Close/*' />
override public void Close()
{
Expand Down