Skip to content

Commit

Permalink
Client throw exception if failed to get client
Browse files Browse the repository at this point in the history
Signed-off-by: yhmo <[email protected]>
  • Loading branch information
yhmo committed Nov 4, 2024
1 parent 51f7e90 commit 476b56c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/io/milvus/pool/ClientPool.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.milvus.pool;

import io.milvus.v2.exception.ErrorCode;
import io.milvus.v2.exception.MilvusClientException;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.slf4j.Logger;
Expand Down Expand Up @@ -51,8 +53,9 @@ public T getClient(String key) {
try {
return clientPool.borrowObject(key);
} catch (Exception e) {
// the pool might return timeout exception if it could not get a client in PoolConfig.maxBlockWaitDuration
logger.error("Failed to get client, exception: ", e);
return null;
throw new MilvusClientException(ErrorCode.CLIENT_ERROR, e);
}
}

Expand All @@ -68,8 +71,9 @@ public void returnClient(String key, T grpcClient) {
try {
clientPool.returnObject(key, grpcClient);
} catch (Exception e) {
// the pool might return exception if the key doesn't exist or the grpcClient doesn't belong to this pool
logger.error("Failed to return client, exception: " + e);
throw e;
throw new MilvusClientException(ErrorCode.CLIENT_ERROR, e);
}
}

Expand Down

0 comments on commit 476b56c

Please sign in to comment.