@@ -683,6 +683,11 @@ public boolean connect(String hostName, int port, int timeout) throws IOExceptio
683
683
}
684
684
685
685
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
+
686
691
this .connectTimeout_ = connectTimeout ;
687
692
this .readTimeout_ = readTimeout ;
688
693
return connect (hostName , port , "" , "" , null , false , null );
@@ -694,6 +699,11 @@ public boolean connect(String hostName, int port, int timeout, boolean reconnect
694
699
}
695
700
696
701
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
+
697
707
this .connectTimeout_ = connectTimeout ;
698
708
this .readTimeout_ = readTimeout ;
699
709
return connect (hostName , port , "" , "" , null , false , null , reconnect );
@@ -705,6 +715,11 @@ public boolean connect(String hostName, int port, int timeout, boolean reconnect
705
715
}
706
716
707
717
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
+
708
723
this .connectTimeout_ = connectTimeout ;
709
724
this .readTimeout_ = readTimeout ;
710
725
return connect (hostName , port , "" , "" , null , false , null , reconnect , tryReconnectNums );
0 commit comments