99import static com .vesoft .nebula .driver .graph .net .Constants .DEFAULT_ENABLE_TLS ;
1010import static com .vesoft .nebula .driver .graph .net .Constants .DEFAULT_MAX_LIFE_TIME_MS ;
1111import static com .vesoft .nebula .driver .graph .net .Constants .DEFAULT_MAX_PING_TIMEOUT_MS ;
12+ import static com .vesoft .nebula .driver .graph .net .Constants .DEFAULT_MAX_WAIT_MS ;
1213
1314import com .vesoft .nebula .driver .graph .data .HostAddress ;
1415import com .vesoft .nebula .driver .graph .exception .AuthFailedException ;
@@ -75,8 +76,8 @@ private NebulaPool(Builder builder) throws IOErrorException, AuthFailedException
7576 }
7677
7778 ClientPoolFactory factory = new ClientPoolFactory (
78- loadBalancer ,
79- builder );
79+ loadBalancer ,
80+ builder );
8081 pool = new GenericObjectPool <>(factory , objConfig );
8182 hasInit .compareAndSet (false , true );
8283 }
@@ -96,7 +97,7 @@ public NebulaClient getClient() throws Exception {
9697 */
9798 public void returnClient (NebulaClient client ) {
9899 if (client .isClosed ()
99- || (System .currentTimeMillis () - client .getCreateTime ()) >= maxLifeMills ) {
100+ || (System .currentTimeMillis () - client .getCreateTime ()) >= maxLifeMills ) {
100101 try {
101102 pool .invalidateObject (client );
102103 } catch (Exception e ) {
@@ -168,7 +169,7 @@ public static class Builder {
168169
169170 // the max wait time if blockWhenExhausted is true. if value is less than 0, always wait.
170171 // unit: millisecond
171- protected long maxWaitMills = Constants . DEFAULT_MAX_WAIT_MS ;
172+ protected long maxWaitMills = DEFAULT_MAX_WAIT_MS ;
172173
173174 // the schedule time for test the idle session and evict it. if value is less than 0,
174175 // never evict the idle sessions.
@@ -272,7 +273,7 @@ public Builder withMinClientSize(int minClientSize) {
272273 */
273274 public Builder withConnectTimeoutMills (long connectTimeoutMills ) {
274275 if (connectTimeoutMills <= 0
275- || connectTimeoutMills > Constants .DEFAULT_MAX_TIMEOUT_MS ) {
276+ || connectTimeoutMills > Constants .DEFAULT_MAX_TIMEOUT_MS ) {
276277 this .connectTimeoutMills = Constants .DEFAULT_MAX_TIMEOUT_MS ;
277278 } else {
278279 this .connectTimeoutMills = connectTimeoutMills ;
@@ -289,7 +290,7 @@ public Builder withConnectTimeoutMills(long connectTimeoutMills) {
289290 */
290291 public Builder withRequestTimeoutMills (long requestTimeoutMills ) {
291292 if (requestTimeoutMills <= 0
292- || requestTimeoutMills > Constants .DEFAULT_MAX_TIMEOUT_MS ) {
293+ || requestTimeoutMills > Constants .DEFAULT_MAX_TIMEOUT_MS ) {
293294 this .requestTimeoutMills = Constants .DEFAULT_MAX_TIMEOUT_MS ;
294295 } else {
295296 this .requestTimeoutMills = requestTimeoutMills ;
@@ -306,7 +307,7 @@ public Builder withRequestTimeoutMills(long requestTimeoutMills) {
306307 */
307308 public Builder withServerPingTimeoutMills (long serverPingTimeoutMills ) {
308309 if (serverPingTimeoutMills < 0
309- || serverPingTimeoutMills > DEFAULT_MAX_PING_TIMEOUT_MS ) {
310+ || serverPingTimeoutMills > DEFAULT_MAX_PING_TIMEOUT_MS ) {
310311 this .serverPingTimeoutMills = DEFAULT_MAX_PING_TIMEOUT_MS ;
311312 } else {
312313 this .serverPingTimeoutMills = serverPingTimeoutMills ;
@@ -357,7 +358,11 @@ public Builder withTestOnBorrow(boolean testOnBorrow) {
357358 * @return NebulaPool.Builder
358359 */
359360 public Builder withMaxWaitMills (long maxWaitMills ) {
360- this .maxWaitMills = maxWaitMills <= 0 ? Long .MAX_VALUE : maxWaitMills ;
361+ if (maxWaitMills <= 0 || maxWaitMills > DEFAULT_MAX_WAIT_MS ) {
362+ this .maxWaitMills = DEFAULT_MAX_WAIT_MS ;
363+ } else {
364+ this .maxWaitMills = maxWaitMills ;
365+ }
361366 return this ;
362367 }
363368
0 commit comments