From: Cheena Malhotra Date: Fri, 15 Nov 2019 19:05:54 +0000 (-0800) Subject: Fixes SqlClient behavior of sending Attention signal for successful Bulk Copy operati... X-Git-Tag: submit/tizen/20210909.063632~11006 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=666923a074f2629e43c1a2a73f6f1f13ddf7fadd;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fixes SqlClient behavior of sending Attention signal for successful Bulk Copy operation (#61) --- diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs index 2b2167f..8effcec 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs @@ -2561,7 +2561,7 @@ namespace System.Data.SqlClient if (_stateObj != null) { - CleanUpStateObjectOnError(); + CleanUpStateObject(); } } catch (OutOfMemoryException) @@ -2584,7 +2584,7 @@ namespace System.Data.SqlClient } // Cleans the stateobj. Used in a number of places, specially in exceptions. - private void CleanUpStateObjectOnError() + private void CleanUpStateObject(bool isCancelRequested = true) { if (_stateObj != null) { @@ -2594,7 +2594,7 @@ namespace System.Data.SqlClient _stateObj.ResetBuffer(); _stateObj.ResetPacketCounters(); // If _parser is closed, sending attention will raise debug assertion, so we avoid it (but not calling CancelRequest). - if (_parser.State == TdsParserState.OpenNotLoggedIn || _parser.State == TdsParserState.OpenLoggedIn) + if (isCancelRequested && (_parser.State == TdsParserState.OpenNotLoggedIn || _parser.State == TdsParserState.OpenLoggedIn)) { _stateObj.CancelRequest(); } @@ -2655,7 +2655,7 @@ namespace System.Data.SqlClient _localColumnMappings = null; try { - CleanUpStateObjectOnError(); + CleanUpStateObject(); } finally { @@ -2671,7 +2671,7 @@ namespace System.Data.SqlClient _localColumnMappings = null; try { - CleanUpStateObjectOnError(); + CleanUpStateObject(isCancelRequested: false); } finally { @@ -2698,11 +2698,11 @@ namespace System.Data.SqlClient try { - CleanUpStateObjectOnError(); + CleanUpStateObject(isCancelRequested: false); } catch (Exception cleanupEx) { - Debug.Fail("Unexpected exception during CleanUpstateObjectOnError (ignored)", cleanupEx.ToString()); + Debug.Fail($"Unexpected exception during {nameof(CleanUpStateObject)} (ignored)", cleanupEx.ToString()); } if (source != null) @@ -2717,11 +2717,11 @@ namespace System.Data.SqlClient try { - CleanUpStateObjectOnError(); + CleanUpStateObject(); } catch (Exception cleanupEx) { - Debug.Fail("Unexpected exception during CleanUpstateObjectOnError (ignored)", cleanupEx.ToString()); + Debug.Fail($"Unexpected exception during {nameof(CleanUpStateObject)} (ignored)", cleanupEx.ToString()); } if (source != null)