FtpTargetTest and pool improvement
This commit is contained in:
@@ -41,26 +41,24 @@ public class QueuedFTPClientPool implements FTPClientPool {
|
||||
|
||||
private final Queue<FTPClient> pool;
|
||||
|
||||
private FTPClientConfig config;
|
||||
private volatile FTPClientConfig config;
|
||||
|
||||
private String host;
|
||||
private volatile String host;
|
||||
|
||||
private int port = FTP.DEFAULT_PORT;
|
||||
private volatile int port = FTP.DEFAULT_PORT;
|
||||
|
||||
private String user;
|
||||
private volatile String user;
|
||||
|
||||
private String pass;
|
||||
private volatile String pass;
|
||||
|
||||
private FTPClientFactory factory = new DefaultFactory();
|
||||
private volatile FTPClientFactory factory = new DefaultFactory();
|
||||
|
||||
private final Log log = LogFactory.getLog(this.getClass());
|
||||
|
||||
|
||||
public QueuedFTPClientPool() {
|
||||
this(DEFAULT_POOL_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param maxPoolSize the maximum size of the pool
|
||||
*/
|
||||
@@ -73,7 +71,7 @@ public class QueuedFTPClientPool implements FTPClientPool {
|
||||
}
|
||||
|
||||
public synchronized void releaseClient(FTPClient client) {
|
||||
if (client != null) {
|
||||
if (client != null && client.isConnected()) {
|
||||
if (!pool.offer(client)) {
|
||||
try {
|
||||
client.disconnect();
|
||||
@@ -115,7 +113,6 @@ public class QueuedFTPClientPool implements FTPClientPool {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
|
||||
private class DefaultFactory implements FTPClientFactory {
|
||||
|
||||
public FTPClient getClient() throws SocketException, IOException {
|
||||
|
||||
Reference in New Issue
Block a user