fix: pool throw exceptipn
parent
32167310dd
commit
31ad07bae8
|
@ -55,7 +55,7 @@ public class ConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Connection getConnection() throws MyException {
|
public Connection getConnection() throws MyException, IOException {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
Connection connection = null;
|
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");
|
throw new MyException("get connection fail, wait_time greater than " + ClientGlobal.g_connection_pool_max_wait_time_in_ms + "ms");
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new MyException("get connection fail, emsg > " + e.getMessage());
|
throw new MyException("get connection fail, emsg:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
System.err.println("get connection ERROR , emsg:" + e.getMessage());
|
||||||
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class ConnectionPool {
|
||||||
*/
|
*/
|
||||||
private final static ConcurrentHashMap<String, ConnectionManager> CP = new ConcurrentHashMap<String, ConnectionManager>();
|
private final static ConcurrentHashMap<String, ConnectionManager> CP = new ConcurrentHashMap<String, ConnectionManager>();
|
||||||
|
|
||||||
public static Connection getConnection(InetSocketAddress socketAddress) throws MyException {
|
public static Connection getConnection(InetSocketAddress socketAddress) throws MyException, IOException {
|
||||||
if (socketAddress == null) {
|
if (socketAddress == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue