Skip to content

Commit 66e2607

Browse files
author
chengyitian
committed
AJ-767: add param check for 'connectTimeout'、'readTimeout';
1 parent edb820b commit 66e2607

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/com/xxdb/DBConnection.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ public boolean connect(String hostName, int port, int timeout) throws IOExceptio
683683
}
684684

685685
public boolean connect(String hostName, int port, int connectTimeout, int readTimeout) throws IOException {
686+
if (connectTimeout < 0 || readTimeout < 0) {
687+
log.error("The param connectTimeout or readTimeout cannot less than zero.");
688+
return false;
689+
}
690+
686691
this.connectTimeout_ = connectTimeout;
687692
this.readTimeout_ = readTimeout;
688693
return connect(hostName, port, "", "", null, false, null);
@@ -694,6 +699,11 @@ public boolean connect(String hostName, int port, int timeout, boolean reconnect
694699
}
695700

696701
public boolean connect(String hostName, int port, int connectTimeout, int readTimeout, boolean reconnect) throws IOException {
702+
if (connectTimeout < 0 || readTimeout < 0) {
703+
log.error("The param connectTimeout or readTimeout cannot less than zero.");
704+
return false;
705+
}
706+
697707
this.connectTimeout_ = connectTimeout;
698708
this.readTimeout_ = readTimeout;
699709
return connect(hostName, port, "", "", null, false, null, reconnect);
@@ -705,6 +715,11 @@ public boolean connect(String hostName, int port, int timeout, boolean reconnect
705715
}
706716

707717
public boolean connect(String hostName, int port, int connectTimeout, int readTimeout, boolean reconnect, int tryReconnectNums) throws IOException {
718+
if (connectTimeout < 0 || readTimeout < 0) {
719+
log.error("The param connectTimeout or readTimeout cannot less than zero.");
720+
return false;
721+
}
722+
708723
this.connectTimeout_ = connectTimeout;
709724
this.readTimeout_ = readTimeout;
710725
return connect(hostName, port, "", "", null, false, null, reconnect, tryReconnectNums);

0 commit comments

Comments
 (0)