Skip to content
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 @@ -825,14 +825,6 @@ public void init() throws SQLException {
this.transactionIdSeedUpdater.addAndGet(this, delta);
}

if (connectTimeout == 0) {
connectTimeout = DEFAULT_TIME_CONNECT_TIMEOUT_MILLIS;
}

if (socketTimeout == 0) {
socketTimeout = DEFAULT_TIME_SOCKET_TIMEOUT_MILLIS;
}

if (this.jdbcUrl != null) {
this.jdbcUrl = this.jdbcUrl.trim();
initFromWrapDriverUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public void test_timeout_is_zero() throws Exception {
assertEquals(0, ds.getConnectTimeout());
assertEquals(0, ds.getSocketTimeout());
}

@Test
public void test_timeout_is_zero_default() throws Exception {
ds.setUrl("jdbc:mysql://127.0.0.1:3306/xxx");
ds.init();
assertEquals(0, ds.getConnectTimeout());
assertEquals(0, ds.getSocketTimeout());
}
@Test
public void test_timeout_is_zero2() throws Exception {
ds.setUrl("jdbc:mysql://127.0.0.1:3306/xxx");
Expand All @@ -61,17 +69,24 @@ public void test_timeout_is_zero2() throws Exception {

/**
* @throws Exception
* @see https://github.com/alibaba/druid/issues/5396
* @see <a href="https://github.com/alibaba/druid/issues/5396">...</a>
*/
@Test
public void test_timeout_in_loadbalance() throws Exception {
ds.setUrl(
"jdbc:mysql:loadbalance://localhost:3306,localhost:3310/test?connectTimeout=98&socketTimeout=99&loadBalanceConnectionGroup=first&ha.enableJMX=true");
ds.init();
assertEquals(98, ds.getConnectTimeout());
assertEquals(99, ds.getSocketTimeout());
}
@Test
public void test_timeout_is_zero_in_loadbalance() throws Exception {
ds.setUrl(
"jdbc:mysql:loadbalance://localhost:3306,localhost:3310/test?connectTimeout=0&socketTimeout=0&loadBalanceConnectionGroup=first&ha.enableJMX=true");
ds.init();
assertEquals(0, ds.getConnectTimeout());
assertEquals(0, ds.getSocketTimeout());
}

@Test
public void test_timeout_in_replication() throws Exception {
ds.setUrl(
Expand Down