| Bug #13775 | Extraneous sleep on autoReconnect | ||
|---|---|---|---|
| Submitted: | 5 Oct 2005 16:35 | Modified: | 22 Nov 2005 5:08 |
| Reporter: | DAN MACDONALD | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S4 (Feature request) |
| Version: | 3.1.10 | OS: | |
| Assigned to: | Mark Matthews | CPU Architecture: | Any |
[22 Nov 2005 5:08]
Mark Matthews
Fixed for 3.1.12 and 5.0.0, see nightly snapshots from http://downloads.mysql.com/snapshots.php#connector-j for fix to test after 00:00 GMT Nov 23rd, when the next build occurs. Thanks for the bug report.

Description: There is an additional sleep before hard failure which delays the application notification by timeout past the last attempt. Really it adds no value as the connection won't be attempted again. for (int attemptCount = 0; (attemptCount < getMaxReconnects()) && !connectionGood; attemptCount++) { // ... attempt connection retrieval // On failure - at this point if we are going to break out of the // loop on the next evaluation, why the frivolous sleep? try { Thread.sleep((long) timeout * 1000); // line 2724 timeout = timeout * 2; } catch (InterruptedException IE) { ; } } How to repeat: Read the code. Suggested fix: for (int attemptCount = 0; (attemptCount < getMaxReconnects()) && !connectionGood; attemptCount++) { // Only sleep if it's not the first attempt if ( attemptCount > 0 ) { try { Thread.sleep((long) timeout * 1000); timeout = timeout * 2; } catch (InterruptedException IE) { ; } } // ... attempt connection retrieval }