| Bug #87316 | Setting CommandTimeout=-1 doesn't throw ArgumentException | ||
|---|---|---|---|
| Submitted: | 4 Aug 2017 6:02 | Modified: | 30 Jul 2020 21:42 |
| Reporter: | Bradley Grainger (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / NET | Severity: | S3 (Non-critical) |
| Version: | 6.9.9 | OS: | Windows (10.0.15063 x64) |
| Assigned to: | CPU Architecture: | Any | |
[4 Aug 2017 6:33]
Chiranjeevi Battula
Hello Bradley Grainger, Thank you for the bug report and test case. Verified this behavior on Visual Studio 2013 (C#.Net) and Connector/NET 6.9.9 version. Thanks, Chiranjeevi.
[4 Aug 2017 6:34]
Chiranjeevi Battula
Screenshot
Attachment: 87316.JPG (image/jpeg, text), 202.19 KiB.
[30 Jul 2020 21:42]
Christine Cole
Posted by developer: Fixed as of the upcoming MySQL Connector/NET 8.0.22 release, and here's the proposed changelog entry from the documentation team: No error occurred when MySqlCommand.CommandTimeout was set to a negative number, however, subsequently setting it to a positive number returned an exception. Thank you for the bug report.

Description: The argument validation logic in the MySqlCommand.CommandTimeout setter is incorrect, and allows CommandTimeout to be set to a negative value. (Setting it to a valid value subsequently will throw an ArgumentException.) How to repeat: var command = new MySqlCommand(); Console.WriteLine("setting CommandTimeout to -1"); command.CommandTimeout = -1; // doesn't throw Console.WriteLine("setting CommandTimeout to 100"); command.CommandTimeout = 100; // throws "ArgumentException: Command timeout must not be negative" Suggested fix: Change https://github.com/mysql/mysql-connector-net/blob/5864e6b21a8b32f5154b53d1610278abb3cb1cee... from: if (commandTimeout < 0) to: if (value < 0)