FtpTargetTest and pool improvement

This commit is contained in:
Iwein Fuld
2008-08-15 13:25:10 +00:00
parent 08252fdbaf
commit 32f4722ee4
3 changed files with 117 additions and 18 deletions

View File

@@ -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 {