From 31ad07bae8e9682470a633d106a0a480b3832a78 Mon Sep 17 00:00:00 2001 From: tanyawen Date: Sun, 29 Dec 2019 09:18:23 +0800 Subject: [PATCH] fix: pool throw exceptipn --- .../java/org/csource/fastdfs/pool/ConnectionManager.java | 7 ++++--- src/main/java/org/csource/fastdfs/pool/ConnectionPool.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java b/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java index fee3b16..5922ca6 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionManager.java @@ -55,7 +55,7 @@ public class ConnectionManager { } - public Connection getConnection() throws MyException { + public Connection getConnection() throws MyException, IOException { lock.lock(); try { Connection connection = null; @@ -81,13 +81,14 @@ public class ConnectionManager { throw new MyException("get connection fail, wait_time greater than " + ClientGlobal.g_connection_pool_max_wait_time_in_ms + "ms"); } catch (InterruptedException e) { e.printStackTrace(); - throw new MyException("get connection fail, emsg > " + e.getMessage()); + throw new MyException("get connection fail, emsg:" + e.getMessage()); } } return connection; } } catch (IOException e) { - return null; + System.err.println("get connection ERROR , emsg:" + e.getMessage()); + throw e; } finally { lock.unlock(); } diff --git a/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java b/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java index 6179d6a..b192137 100644 --- a/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java +++ b/src/main/java/org/csource/fastdfs/pool/ConnectionPool.java @@ -13,7 +13,7 @@ public class ConnectionPool { */ private final static ConcurrentHashMap CP = new ConcurrentHashMap(); - public static Connection getConnection(InetSocketAddress socketAddress) throws MyException { + public static Connection getConnection(InetSocketAddress socketAddress) throws MyException, IOException { if (socketAddress == null) { return null; }