Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffery-Wasty committed Sep 19, 2024
1 parent b5c01ad commit f8b33e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,6 @@ Connection connect(Properties propsIn, SQLServerPooledConnection pooledConnectio
}
throw e;
} else {

// only retry if transient error
SQLServerError sqlServerError = e.getSQLServerError();
if (!TransientError.isTransientError(sqlServerError)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
package com.microsoft.sqlserver.jdbc;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.IOException;
import java.io.Reader;
Expand Down Expand Up @@ -194,7 +193,7 @@ public void testDataSource() throws SQLServerException {
assertEquals("False", EncryptOption.valueOfString(ds.getEncrypt()).toString(),
TestResource.getResource("R_valuesAreDifferent"));

// verify encrypt=strict options
// verify enrypt=strict options
ds.setEncrypt(EncryptOption.STRICT.toString());
assertEquals("Strict", EncryptOption.valueOfString(ds.getEncrypt()).toString(),
TestResource.getResource("R_valuesAreDifferent"));
Expand Down Expand Up @@ -486,7 +485,7 @@ private void testConnectCountInLoginAndCorrectRetryCount(int connectRetryCount)
timerStart = System.currentTimeMillis();

try (Connection con = ds.getConnection()) {
assertNull(con, TestResource.getResource("R_shouldNotConnect"));
assertTrue(con == null, TestResource.getResource("R_shouldNotConnect"));
}
} catch (Exception e) {
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ public static void setupTests() throws Exception {
/*
* TODO:
* The tests below uses a simple interval counting logic to determine whether there was at least 1 retry.
* Given the interval is long enough, then 1 retry should take at least 1 interval long, so if it took < 1 interval,
* then it assumes there were no retry. However, this only works if TNIR or failover is not enabled since those cases
* should retry but no wait interval in between. So this interval counting can not detect these cases.
* Note a better and more reliable way would be to check attemptNumber using reflection to
* determine the number of retries.
* Given the interval is long enough, then 1 retry should take at least 1 interval long, so if it took < 1 interval, then it assumes there were no retry. However, this only works if TNIR or failover is not enabled since those cases should retry but no wait interval in between. So this interval counting can not detect these cases.
* Note a better and more reliable way would be to check attemptNumber using reflection to determine the number of retries.
*/

// test default loginTimeout used if not specified in connection string
Expand All @@ -80,7 +77,7 @@ public void testDefaultLoginTimeout() {

// time should be < default loginTimeout
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(defaultTimeout),
"total time: " + totalTime + " default logintimeout: " + TimeUnit.SECONDS.toMillis(defaultTimeout));
"total time: " + totalTime + " default loginTimout: " + TimeUnit.SECONDS.toMillis(defaultTimeout));
}

// test setting loginTimeout value
Expand All @@ -92,7 +89,7 @@ public void testURLLoginTimeout() {
long timerStart = System.currentTimeMillis();

// non existing server and set loginTimeout
try (Connection con = PrepUtil.getConnection("jdbc:sqlserver://" + randomServer + ";loginTimout=" + timeout)) {
try (Connection con = PrepUtil.getConnection("jdbc:sqlserver://" + randomServer + ";logintimeout=" + timeout)) {
fail(TestResource.getResource("R_shouldNotConnect"));
} catch (Exception e) {
totalTime = System.currentTimeMillis() - timerStart;
Expand Down Expand Up @@ -205,7 +202,7 @@ public void testConnectRetryDisable() {
"total time: " + totalTime + " interval: " + TimeUnit.SECONDS.toMillis(interval));
}

// Test connect retry for non existent server with loginTimeout
// Test connect retry for non-existent server with loginTimeout
@Test
public void testConnectRetryBadServer() {
long totalTime = 0;
Expand Down

0 comments on commit f8b33e1

Please sign in to comment.